Homepage
Link to WPGraphQL on Github
Link to WPGraphQL on WordPress.org

register_graphql_mutation

Given a Mutation Name and Config array, this adds a Mutation to the Schema

Parameters

  • $mutation_name (string): The name of the mutation
  • $config (array): Configuration for the mutation
    • $description (string): Description of the mutation type.
    • $inputFields (array): The input fields for the mutation
      • $type (string): The name of the Type in the Schema the field should accept. Note: ObjectTypes cannot be used as Input Types.
      • $description (string): The field description.
    • $outputFields (array): The output field for the mutation (what can be asked for in response)
    • $mutateAndGetPayload (function): How the mutation should resolve

Source

File: access-functions.php

Example

Here is a basic example of registering a mutation:

Registering the above mutation would allow for the following mutation to be executed:

And the following response would be provided: