Skip to content

GraphQL Query

This module extends the basic GraphQL module functionality by adding support for automatic cursor-based pagination. It allows executing GraphQL queries against any endpoint, and if the edgePath and pageInfoPath parameters are configured, it automatically traverses all result pages using the relay pagination pattern (edges/nodes with cursor).

The module iterates until hasNextPage is false or the configured page limit (maxPages) is reached. On each iteration, it sends the after variable with the previous page’s cursor. It uses lodash to extract response data according to the configured paths.

ParameterTypeRequiredDescription
credentials_idcredentialsYesCredentials with username and password for Basic Auth
endpointtextYesGraphQL endpoint URL
querytextYesGraphQL query with support for $after variable
variablesjsonNoGraphQL query variables
xtremEndpointtextNoValue for x-xtrem-endpoint header (default: DEV)
clientCookietextNoClient session cookie
edgePathtextNoPath in the response where edges are found (e.g.: repository.issues.edges). If not specified, returns the response without pagination
pageInfoPathtextNoPath in the response where pageInfo is found (e.g.: repository.issues.pageInfo)
maxPagesnumberNoMaximum number of pages to traverse (default: 20)

Credentials are obtained from the credentials system and must contain:

  • username: Username for Basic Auth
  • password: Password for Basic Auth
  • clientCookie: Client session cookie (optional)
{
"nextModule": "siguiente_modulo",
"data": [
{ "id": "1", "title": "Issue 1", "state": "OPEN" },
{ "id": "2", "title": "Issue 2", "state": "CLOSED" }
]
}
{
"credentials_id": 1,
"endpoint": "https://api.ejemplo.com/graphql",
"query": "query($after: String) { repository(name: \"repo\") { issues(first: 100, after: $after) { edges { node { id title state } } pageInfo { hasNextPage endCursor } } } }",
"edgePath": "repository.issues.edges",
"pageInfoPath": "repository.issues.pageInfo",
"maxPages": 10
}
{
"credentials_id": 1,
"endpoint": "https://api.ejemplo.com/graphql",
"query": "query { user(id: 1) { name email } }"
}
  • User-configured GraphQL endpoint
  • Protocol: HTTP POST with Content-Type application/json
  • If edgePath and pageInfoPath are not configured, the module behaves as a simple query without pagination
  • The supported pagination pattern is relay (edges/nodes with cursor)
  • The after variable is automatically injected into the query variables
  • The default limit is 20 pages to prevent infinite loops
  • Nodes are automatically extracted from edge.node
  • Paginated results are accumulated in a single array
  • Uses lodash (_.get) to extract data from nested paths
  • Uses node-fetch for HTTP requests
  • graphql (version without pagination)