Deprecating a field in the Schema

Sometimes it can be helpful to deprecate a field in the Schema without removing it altogether. This snippet shows how to deprecate the `Post.excerpt` field. You can use this technique to deprecate other fields. After using this snippet, we can verify in the WPGraphQL Schema Docs that the field is indeed deprecated:

Register a basic Mutation

This snippet shows how to register a basic GraphQL Mutation with a single input field, a single output field, and the input is simply returned as the value for the output.

Add Edit Link to All Post Types

The following snippet shows how to add the “Edit” link as a GraphQL field to all post types: This could then be queried like so:

Add field to output URLs for Sitemap

The following code is an example of how you can create a field called allUrls that will output site URLs that could be used to generate a sitemap. The resolver uses mostly hard-coded data, but shows what a potential solution could look like. You can then query this field using:

List of Key Values

This is an example showing how to return a list of keys and values where the keys and values are both strings.

Add field for unencoded content

The following adds a field to the NodeWithContentEditor interface to get the unencoded content for a post: You can query now query for this field: Related Links Github issue: https://github.com/wp-graphql/wp-graphql/issues/1035#issuecomment-691232395