Communicating with GraphQL

HTTP is commonly associated with REST, which uses "resources" as its core concept. In contrast, GraphQL's conceptual model is an entity graph. As a result, entities in GraphQL are not identified by URLs. Instead, a GraphQL server operates on a single URL/endpoint, usually /graphql, and all GraphQL requests for a given service should be directed at this endpoint.

GraphQL operations consist of multiline JSON . We recommend to use a GraphQL client library or you can also use cURL or any other HTTP-speaking library.

In REST, HTTP verbs determine the operation performed. In GraphQL, you'll provide a JSON-encoded body whether you're performing a query or a mutation, so the HTTP verb is POST. The exception is an introspection query, which is a simple GET to the endpoint.

A standard GraphQL request should use the application/json content type, and include a JSON-encoded body of the following form:

1 2 3 4 5 { "query": "...", "operationName": "...", "variables": { "myVariable": "someValue", ... } }

operationName and variables are optional fields. operationName is only required if multiple operations are present in the query.

Next steps