GraphQL Query
Description
Section titled “Description”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.
Configuration
Section titled “Configuration”| Parameter | Type | Required | Description |
|---|---|---|---|
| credentials_id | credentials | Yes | Credentials with username and password for Basic Auth |
| endpoint | text | Yes | GraphQL endpoint URL |
| query | text | Yes | GraphQL query with support for $after variable |
| variables | json | No | GraphQL query variables |
| xtremEndpoint | text | No | Value for x-xtrem-endpoint header (default: DEV) |
| clientCookie | text | No | Client session cookie |
| edgePath | text | No | Path in the response where edges are found (e.g.: repository.issues.edges). If not specified, returns the response without pagination |
| pageInfoPath | text | No | Path in the response where pageInfo is found (e.g.: repository.issues.pageInfo) |
| maxPages | number | No | Maximum number of pages to traverse (default: 20) |
Credentials
Section titled “Credentials”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)
Output
Section titled “Output”{ "nextModule": "siguiente_modulo", "data": [ { "id": "1", "title": "Issue 1", "state": "OPEN" }, { "id": "2", "title": "Issue 2", "state": "CLOSED" } ]}Usage Example
Section titled “Usage Example”Basic case - Paginated query
Section titled “Basic case - Paginated query”{ "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}Basic case - Simple query (no pagination)
Section titled “Basic case - Simple query (no pagination)”{ "credentials_id": 1, "endpoint": "https://api.ejemplo.com/graphql", "query": "query { user(id: 1) { name email } }"}API Used
Section titled “API Used”- 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
aftervariable 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
Related Nodes
Section titled “Related Nodes”- graphql (version without pagination)