From 6533a2f116886beabd8e8cde3e1d3c3d20a9a052 Mon Sep 17 00:00:00 2001 From: Matt Thomas Date: Thu, 3 Oct 2019 18:06:49 -0400 Subject: [PATCH] Adds deregister_graphql_field() example --- src/content/extending/fields.mdx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/content/extending/fields.mdx b/src/content/extending/fields.mdx index eeb2d78..f6e2008 100644 --- a/src/content/extending/fields.mdx +++ b/src/content/extending/fields.mdx @@ -3,13 +3,25 @@ title: GraphQL Fields API Reference description: Learn how to register, deregister and filter GraphQL fields --- -## Register Fields to the Schema +## Register/Deregister Fields to the Schema `@todo: Document the registration API` - **register_graphql_field()** - **deregister_graphql_field()** +To deregister, or remove, a field from the schema, simply call [`deregister_graphql_field( $type_name, $field_name )`](https://github.com/wp-graphql/wp-graphql/blob/develop/access-functions.php#L164). For example, to deregister the automatically registered _By_ root field for the custom post type _fooBar_: + +``` +add_action( + 'graphql_register_types', function () { + deregister_graphql_field( 'RootQuery', 'fooBarBy' ); + } +); + +``` + + Register field for custom post ```