ePublishing GraphQL API Reference
This page is an index for a detailed reference of our GraphQL API, as generated from our schema by GraphQL introspection.
Resources
- Just starting out with GraphQL? Check out GraphQL's official documentation.
- For an overview of our GraphQL API see the Introduction to GraphQL Knowledge Base article.
- The Examples page links to dozens of example queries and mutations. There are examples for each type and mutation and several on different topics. The examples open in the GraphiQL IDE for the site.
- GraphiQL is our fork of graphql/graphiql. It is an integrated development environment for GraphQL with a documentation browser, history browser, auto-complete, etc. It makes it easy to browse the database and rapidly iterate on query designs.
- The Release Notes document API changes.
Calling the API
API requests are POST requests to https://<site domain>/query. The site domain can be for either the stage or production site. The Content-Type header must be application/json. The "query" data sent with the post must be in the GraphQL language. The "variables" data must be in JSON. The response to the request will be in JSON.
With the exception of a tokenCreate mutation and a standard introspection query, all queries require an authorization token. To get a token use the tokenCreate mutation (example below), which requires a user email and password. Tokens expire in a configurable amount of time. Include that token in the Authorization header of subsequent queries with the format token <token>.
curl Examples
# create an authorization token
curl \
-X POST \
-H "Content-Type: application/json" \
--data '{"query": "mutation { tokenCreate(email: \"<email>\", password: \"<password>\", admin: true) { token expiresAt } }"}' \
https://<site domain>/query
# read
curl \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: token <token>" \
--data '{"query": "query { articles(perPage: 2) { id title } }"}' \
https://<site domain>/query
# write
curl \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: token <token>" \
--data '{"query": "mutation { articleUpdate(input: { ids: \"MWUtNjc=\", title: \"foo\" }) { articles { id title } } }"}' \
https://<site domain>/query
# read with variables
curl \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: token <token>" \
--data '{"query": "query ($perPage: Integer) { articles(perPage: $perPage) { id title } }", "variables": "{ \"perPage\": 2 }" }' \
https://<site domain>/query
To convert these into other languages see curlconverter or curl-to-ruby.