POST /graphql • HTTP 200 OK

GraphQL Query over HTTP POST API Example — Request & Response Example

Demonstrates how GraphQL queries travel over the HTTP protocol: submitting a query payload and variables inside a standard POST request.

1. HTTP Client Request (POST)

POST /graphql HTTP/1.1
{
  "Content-Type": "application/json",
  "Accept": "application/json"
}

{
  "query": "query GetProject($id: ID!) {\n  project(id: $id) {\n    name\n    status\n    owner {\n      username\n      email\n    }\n  }\n}",
  "variables": {
    "id": "proj_8820"
  }
}

2. Server JSON Response (HTTP 200 OK)

{
  "data": {
    "project": {
      "name": "Cometflow Space v2",
      "status": "DEPLOYED",
      "owner": {
        "username": "lead_dev",
        "email": "dev@cometflow.space"
      }
    }
  }
}

Copy-Paste Code Snippets (cURL, JavaScript Fetch, Python, Node.js)

curl -X POST "https://cometflow.space/graphql" \
  -H "Content-Type: application/json" \
  -d '{"query": "query { project(id: \"proj_8820\") { name status } }"}'
fetch('https://cometflow.space/graphql', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    query: 'query { project(id: "proj_8820") { name status } }'
  })
}).then(res => res.json()).then(console.log);
import requests

payload = {
    "query": "query { project(id: \"proj_8820\") { name status } }"
}
res = requests.post("https://cometflow.space/graphql", json=payload)
print(res.json()['data'])

How This API Call Works Step-by-Step

  1. 1. Client prepares GraphQL query string specifying exact fields requested.
  2. 2. Query and variables wrapped into standard JSON POST body.
  3. 3. GraphQL execution engine on server parses abstract syntax tree (AST) and executes field resolvers.
  4. 4. Server returns JSON object formatted under data: { ... }.

Backend API Functions: The GraphQL handler function executeGraphQL({ schema, document, variableValues }) resolves each requested field and constructs the structured response.

Frequently Asked Questions

Why does GraphQL use HTTP POST even for read queries?

GraphQL query strings are often complex and hierarchical, making them too long to reliably fit inside an HTTP GET URL string. POST allows sending queries of any size in the request body.