Skip to content

Latest commit

 

History

History
89 lines (65 loc) · 2.55 KB

File metadata and controls

89 lines (65 loc) · 2.55 KB

Release Notes: 0.7

Mutations

Added support for GraphQL mutations!

Mutations in the schema docs

Through mutations, you are now able to modify data through your GraphQL queries:

mutation {
  updatePost(id: 5, title: "New title") {
    title
  }
}

New mutation fields

The following mutation fields have been added to the schema:

  • createPost
  • updatePost
  • setFeaturedImageforCustomPost
  • removeFeaturedImageforCustomPost
  • addCommentToCustomPost
  • replyComment
  • loginUser
  • logoutUser

Nested mutations

Nested mutations is the ability to perform mutations on a type other than the root type in GraphQL.

For instance, the mutation query from above can also be executed through this nested mutation, on type Post:

mutation {
  post(id: 5) {
    update(title: "New title") {
      title
    }
  }
}

Mutations can also modify data on the result from another mutation:

mutation {
  createPost(title: "First title") {
    id
    update(title: "Second title", content: "Some content") {
      title
      content
      addComment(comment: "My first comment") {
        id
        content
        date
      }
    }
  }
}

Nested mutations have been requested for the GraphQL spec but not yet approved, hence GraphQL API adds support for them as an opt-in feature, via module "Nested Mutations" (which must be enabled).

Nested mutations change the root type, from QueryRoot and MutationRoot, to a single Root type handling both queries and mutations:

Nested mutations in the schema docs

In addition, a "Mutation Scheme" section has been added to a Schema Configuration, allowing to enable/disable nested mutations for a specific Custom Endpoint or Persisted Query.

Mutation scheme in the schema configuration

New nested mutation fields

The following nested mutation fields have been added to the schema:

  • CustomPost.update
  • CustomPost.setFeaturedImage
  • CustomPost.removeFeaturedImage
  • CustomPost.addComment
  • Comment.reply

Support for PHP 8.0

Starting from this version, the plugin runs without any issue in PHP 8.0.