Graphql
Graphql trigger is triggered when new items of a graphql endpoint response are detected.
Usage
Watching new item in API https://countries.trevorblades.com/
response:
on:graphql:url: https://countries.trevorblades.com/itemsPath: data.countriesdeduplicationKey: codequery: |query {countries {codename}}
Options
url
, required, the graphql API URL, for example,https://countries.trevorblades.com/
query
, required, the graphql query, for example:query {countries {codename}}variables
, optional, the graphql variables, the default value is{}
headers
, optional, the graphql endpoint headers, the default value is{}
itemsPath
, optional, you may need to configureitemsPath
as the key that contains the results. Example:data.items
,data.posts
, etc... The default value isdata.items
deduplicationKey
, optional. The graphql trigger deduplicates the array we see each graphql against the id key. If the id key does not exist, you should specify an alternative unique key to deduplicate, you can use path format, like:id
,data.id
,item.data.key
, If neither are supplied, we fallback to looking forkey
, if neither are supplied, we will hash the item, and generate a unique keyshouldIncludeRawBody
, optional,boolean
, the default value isfalse
, iftrue
, then your use the whole body as you need. For example:on:graphql:url: https://countries.trevorblades.com/itemsPath: data.countriesdeduplicationKey: codeshouldIncludeBody: truequery: |query {countries {codename}}jobs:print:name: Printruns-on: ubuntu-lateststeps:- name: Print Outputsenv:rawBody: ${{ toJSON(on.graphql.outputs.raw__body) }}run: |echo "rawBody: $rawBody"requestConfig
, optional, we use Axios for graphql data, so your can pass all params that axios supported. For example:on:graphql:url: https://countries.trevorblades.com/requestConfig:timeout: 30000requestConfig.axios-retry
, optional,axios-retry
params, you can configure the number of times to retry, for example:
on:poll:url: https://fb067a39e21871a3c38f8569d28d5aba.m.pipedream.net/requestConfig:axios-retry:retries: 3jobs:print:name: Printruns-on: ubuntu-lateststeps:- name: Print Outputsenv:title: ${{ on.poll.outputs.id }}run: |echo "title: $title"
You can use General Config for Actionsflow Trigger for more customization.
Outputs
Graphql trigger's outputs will be the item of the API results
Note, is you set
shouldIncludeRawBody
, then you will getraw__body
for the whole raw body
An outputs example:
{"userId": 1,"id": 1,"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit","body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"}
You can use the outputs like this:
on:graphql:url: https://countries.trevorblades.com/itemsPath: data.countriesdeduplicationKey: codequery: |query {countries {codename}}jobs:print:name: Printruns-on: ubuntu-lateststeps:- name: Print Outputsenv:name: ${{ on.graphql.outputs.name }}run: |echo "name: $name"