Skip to content

Make HTTP endpoint compatible with GraphQL best practices #3142

@paulftw

Description

@paulftw

This is a Design Doc for Dgraph v1.1 - a breaking change to make HTTP API more compatible with GraphQL.

Further reading:

In v1.1 Dgraph HTTP endpoints must have following properties:

/query

  1. URL /query accepts HTTP POST with Content-Type application/json and POST body in JSON format:
{
  "query": "...",
  "variables": { "myVariable": "someValue", ... },
  "startTs": <number>,
  "debug": <true/false>,
}
  1. JSON field "query" is required, all other fields are optional.

  2. If the "application/graphql" Content-Type header is present, treat the HTTP POST body contents as the GraphQL query string and read all other fields from the query string e.g. /query?variables=...&startTs=...&debug=true

/mutate

  1. /mutate no longer accepts X-Dgraph-... custom headers. OPTIONS response no longer advertises the headers, if a POST request is received with any of these headers, their presence and values are ignored.

  2. As of dgraph v1.0.13 /mutate accepts X-Dgraph-CommitNow and X-Dgraph-MutationType. Mutation type can be inferred from the Content Type header and thus no replacement is necessary.
    CommitNow can be specified on the URL string: /mutate/<startTs>?commitNow=true

/commit

/commit does not use any of the X-Dgraph-... so no changes to its behavior are necessary.

Metadata

Metadata

Assignees

Labels

kind/maintenanceMaintenance tasks, such as refactoring, with no impact in features.priority/P0Critical issue that requires immediate attention.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions