GraphQL

Send GraphQL requests with the GraphQL built-in.

Request

Perform a request against a GraphQL resource.
FieldTypeDefaultDescription
graphqlResourcestringRequiredThe alias of the GraphQL resource.
operationstringRequiredThe GraphQL query or mutation to execute.
variablesobject nullOptional GraphQL variables.
headersobjectnullOptional object containing request headers.
urlParamsobjectnullOptional object containing urlParams.
retryFailuresbooleanfalseTrue to retry the request on 500, 502, 503, and 504 error codes. Requests will always be retried on 408 and 429 error codes.

Usage

javascript
Copied
1
import airplane from "airplane";
2
3
const operation = `
4
query {
5
users {
6
id
7
name
8
email
9
}
10
}`;
11
12
export default airplane.task(
13
{
14
slug: "get_user_profiles",
15
resources: ["profile_api"],
16
},
17
async (params) => {
18
const run = await airplane.graphql.request(
19
"profile_api", // The slug of the GraphQL resource to query.
20
operation // The operation to execute.
21
);
22
return run.output.data;
23
}
24
);