Making Requests#

All API requests are HTTP POST requests to the GraphQL endpoint with a JSON body.

Endpoint#

POST https://afosto.app/graphql

Required headers#

NameTypeRequiredDescription
Authorization
Header
RequiredBearer YOUR_API_KEY
Content-Type
Header
Requiredapplication/json

Request body#

NameTypeRequiredDescription
query
String
RequiredYour GraphQL query or mutation
variables
Object
OptionalKey/value map of variables referenced in the query
{
  "query": "...",
  "variables": {}
}

Using variables#

Always use variables instead of string interpolation to prevent injection and improve query caching:

# Good
query GetProduct($id: ID!) {
  product(id: $id) {
    id
    name
  }
}
{
  "query": "query GetProduct($id: ID!) { product(id: $id) { id name } }",
  "variables": { "id": "prod_123" }
}

Response format#

Successful responses return HTTP 200 with:

{
  "data": {
    "product": {
      "id": "prod_123",
      "name": "Blue T-Shirt"
    }
  }
}

Errors are returned in an errors array alongside (or instead of) data. See Error Handling for details.

Query Runnerhttps://afosto.app/graphql

No query loaded

Click play on any code block in the docs to load a query here.