Query examples
Query examplesExecuting Queries and Mutations

Executing Queries and Mutations

Here are examples of the two supported operations in the GraphQL server: queries and mutations.

Queries

Use the query operation to retrieve data (similar to a GET operation in REST).

query {
  post(by: { id: 1 }) {
    title
  }
}

Mutations

Use the mutation operation to create, update or delete data (similar to a POST, PUT or DELETE operations in REST).

mutation {
  createPost(
    input: {
      title: "Hi there!"
      contentAs: { html: "How do you like it?" }
      status: draft
      tags: ["demo", "plugin"]
    }
  ) {
    status
    errors {
      __typename
      ...on ErrorPayload {
        message
      }
    }
    postID
  }
}

Bulk mutations

Please read guide Executing bulk mutations.

Handling Mutation Payloads

Please read guide Handling mutation payloads.