Executing Queries and Mutations

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

Queries permalink

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

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

Mutations permalink

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
}
}

Handling Mutation Payloads permalink

Please read guide Handling mutation payloads.