GraphQL API Mapping
GraphQL API Mapping
The GraphQL API Mapping function type lets you map functions to GraphQL API endpoints without writing code. This is useful when the function can be implemented with a single GraphQL query or mutation.
Use the following file naming structure for the GraphQL API mapping implementation:
<method-name>.graphql.yml
Example
# list.graphql.yml
query: |
query GetContacts($limit: Int, $cursor: String, $email: String) {
contacts(first: $limit, after: $cursor, where: { email: $email }) {
edges {
node {
id
firstName
lastName
email
phone
createdAt
updatedAt
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
variables:
limit: 100
cursor:
$var: $.cursor
email:
$var: $.filter.email
responseMapping:
records:
$var: response.data.contacts.edges[*].node
cursor:
$cond:
- $var: response.data.contacts.pageInfo.hasNextPage
- $var: response.data.contacts.pageInfo.endCursor
- null
Format
The GraphQL mapping specification includes:
query
– The GraphQL query or mutation stringvariables
– Variables mapping for the GraphQL queryresponseMapping
– Mapping to transform the GraphQL response
Variables
Besides function-specific input variables described in each function's documentation, GraphQL functions have the following variables available:
- All functions inside the connector have
credentials
variable that contains credentials from the current connection - All data collection functions have
parameters
variable that contains function-level parameters and collection-level parameters combined
For responseMapping
, you get an additional response
variable that has the following fields:
data
– GraphQL response dataerrors
– GraphQL response errors (if any)extensions
– GraphQL response extensions (if any)
Updated about 2 hours ago