How to use the GraphQL API.

    Dgraph serves spec compliant GraphQL over HTTP. By default, GraphQL is served at http://localhost:8080/graphql. Both GET and POST requests are served.

    For POST requests, the body must be "application/json" encoded with the following form.

    "query": "...",
    "operationName": "...",
    "variables": { "var": "val", ... }

    For GET requests, the query, variables and operation are sent as query parameters in the url.


    In both cases, only query is required. variables is only required if the query contains GraphQL variables: i.e. it starts like query myQuery($var: String...). While, operationName is required if there are multiple operations in the query; in which case, operations must also be named.

    Compressed requests and responses are available with gzip. Set header Content-Encoding to gzip to post encoded data, and Accept-Encoding to gzip to receive a compressed response.

    When an operation contains multiple queries, they are run concurrently and independently in a single Dgraph transaction.

    When an operation contains multiple mutations, they are run serially, in the order listed in the request, and in a transaction per mutation. If a mutation fails, the following mutations are not executed, and previous mutations are not rolled back.