On this page
Sommatic Docs
Open portal

GraphQL Client

Execute GraphQL Query or Mutation.

View as Markdown
Open in
Input and output Available io.graphql Version 1.0.0 Execution: async

Sends one GraphQL query or mutation as an HTTP POST to the endpoint of a credential and returns data, or the GraphQL errors through the error port.

How it works

  1. Resolves the config. connection_id, query and variables fall back to the same keys of the incoming payload; connection_id and query are required.
  2. Resolves the credential. The endpoint is config.url (or config.endpoint); extra headers come from config.headers.
  3. Adds authentication from the secret, first match wins: token → Authorization: Bearer, apiKey → header config.headerName (default x-api-key), username + password → Authorization: Basic.
  4. POSTs { query, variables } as JSON.
  5. If the response has a non-empty errors array, leaves through error with { errors }; otherwise returns { data } through out.

In a workflow

The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.

{
  "node_id": "node-fetch-order",
  "label": "Fetch order",
  "operator_slug": "io.graphql",
  "operator_version": "1.0.0",
  "config": {
    "connection_id": "pi-credential-xxxx",
    "query": "query Order($id: ID!) { order(id: $id) { id status } }",
    "variables": {
      "id": "{{ $json.order_id }}"
    }
  }
}

Configuration

connection_id string Required

Credential for the GraphQL endpoint. Accepts credentials of type `api-key`, `basic-auth`, or `oauth2` (bearer token).

query string Required

GraphQL Query/Mutation

variables object Optional

Behaviour in the code

What the implementation does with these keys beyond what the schema says.

connection_id
Accepts basic-auth, oauth2 and object credentials whose secret is an object with token, apiKey or username + password. An api-key credential stored as a plain string adds no header. A value starting with http is used as the endpoint URL itself, without authentication.
variables
Sent as-is; expressions inside are resolved first.

Output ports

out default

The server answered 2xx without GraphQL errors. data is the data field of the GraphQL response.

Data
{
  "data": {
    "order": {
      "id": "ord_123",
      "status": "PAID"
    }
  }
}
error

The response carries GraphQL errors (data is { errors }), or the request failed (data is { error, response }, with response the body of a non-2xx answer).

Data
{
  "errors": [
    {
      "message": "Cannot query field \"stat\" on type \"Order\".",
      "locations": [
        {
          "line": 1,
          "column": 32
        }
      ]
    }
  ]
}

In expressions

What a later node can read from this node's output with $("GraphQL Client").item.json.<path> (write your node's label instead of GraphQL Client). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through out, from the output shown in Ports.

ExpressionEditorWorker
$("GraphQL Client").item.json.dataobject= {…}GraphQL Data
$("GraphQL Client").item.json.errorsarrayThe worker does not return it: reads as undefinedGraphQL Errors —
$("GraphQL Client").item.json.data.orderobjectNot suggested by the editor= {…}—

— Editor: The editor suggests it, but the worker does not return it: it reads as undefined.

— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).

Errors

Message Port Cause and fix
connection_id is required error No credential selected. Pick a GraphQL credential.
query is required error The query is empty in the config and in the incoming payload.
Request failed with status code <status> error The server answered non-2xx. response holds its body. Check the endpoint and the authentication.
Failed to resolve connection <connection_id>: <detail> error The credential does not exist or this workflow cannot use it.

Input contract

connection_id string Required
query string Required
variables object Optional

Output contract

data object Optional

GraphQL Data

errors array Optional

GraphQL Errors

Contracts (JSON Schema)

The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.

{
  "slug": "io.graphql",
  "name": "GraphQL Client",
  "category": "io",
  "version": "1.0.0",
  "description": "Execute GraphQL Query or Mutation.",
  "capabilities": [
    "graphql",
    "api",
    "http"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "connection_id": {
        "type": "string",
        "title": "GraphQL Credential",
        "description": "Credential for the GraphQL endpoint. Accepts credentials of type `api-key`, `basic-auth`, or `oauth2` (bearer token).",
        "ui_widget": "connection_picker",
        "ui_options": {
          "credential_types": [
            "api-key",
            "basic-auth",
            "oauth2"
          ],
          "types": [
            "graphql",
            "http"
          ]
        }
      },
      "query": {
        "type": "string",
        "description": "GraphQL Query/Mutation"
      },
      "variables": {
        "type": "object"
      }
    },
    "required": [
      "connection_id",
      "query"
    ]
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "connection_id": {
        "type": "string"
      },
      "query": {
        "type": "string"
      },
      "variables": {
        "type": "object"
      }
    },
    "required": [
      "connection_id",
      "query"
    ]
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "data": {
        "type": "object",
        "description": "GraphQL Data"
      },
      "errors": {
        "type": "array",
        "description": "GraphQL Errors"
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Data",
      "description": "GraphQL data response",
      "is_default": true,
      "supports_condition": true
    },
    {
      "port_id": "error",
      "label": "Errors",
      "description": "GraphQL errors or network error",
      "is_default": false,
      "supports_condition": false
    }
  ],
  "execution_mode": "async",
  "required_resources": [],
  "compatible_worker_pools": [
    "standard-io"
  ],
  "tags": [
    "graphql",
    "api"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_link_loom",
    "profile": {
      "name": "Link Loom",
      "verified": true,
      "url": "https://me.veripass.com/link-loom",
      "logo_url": null
    }
  }
}

Execution

Execution
async
Stateful
No
Credentials
Resolved on the server from connection_id; the secret never reaches the workflow.
Capabilities
graphqlapihttp
Tags
graphqlapi

Notes and limits

  • A response with both data and errors (partial success) goes to error and the partial data is dropped.
  • No request timeout and no retries are applied.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs