Skip to content

GraphQL

This module allows executing GraphQL queries against any compatible endpoint. It performs a POST request with the provided query and variables, using Basic Auth authentication built from the configured credentials. It includes support for custom headers such as x-xtrem-endpoint and session cookies.

The module sends the query, validates the HTTP response and checks if there are GraphQL errors in the result. If the response is successful, it returns the data directly. If there are GraphQL errors, it reports them with full detail.

ParameterTypeRequiredDescription
credentials_idcredentialsYesCredentials with username and password for Basic Auth
endpointtextYesGraphQL endpoint URL
querytextYesGraphQL query to execute
variablesjsonNoGraphQL query variables
xtremEndpointtextNoValue for x-xtrem-endpoint header (default: DEV)
clientCookietextNoClient session cookie

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": {
"users": [
{ "id": "1", "name": "Juan", "email": "juan@ejemplo.com" }
]
}
}
{
"credentials_id": 1,
"endpoint": "https://api.ejemplo.com/graphql",
"query": "query { users { id name email } }",
"variables": {},
"xtremEndpoint": "PROD"
}
  • User-configured GraphQL endpoint
  • Protocol: HTTP POST with Content-Type application/json
  • Uses node-fetch for HTTP requests
  • Authentication is Basic Auth (Base64 of username:password)
  • GraphQL errors are reported with the message and full details
  • Does not support automatic pagination (use the graphqlQuery module for that)
  • The x-xtrem-endpoint header is specific to certain services and can be omitted
  • If no variables are provided, an empty object is sent
  • graphqlQuery (version with automatic pagination)