Skip to content
This repository has been archived by the owner on Nov 15, 2020. It is now read-only.

Adds deregister_graphql_field() example #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/content/extending/fields.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

```
Expand Down