register_graphql_field
register_graphql_field( string $type_name, string $field_name, array $config ): void;
Given a Type Name, Field Name, and a $config array, this adds a Field to a registered Type in the TypeRegistry
- Since: 0.1.0
- Source File:
plugins/wp-graphql/access-functions.php
Parameters
$type_name(string): The name of the Type to add the field to$field_name(string): The name of the Field to add to the Type$config(array<string,mixed>): The Type config
Throws
\Exception
Recipes
- Add Edit Link to All Post Types
- Add field for unencoded content
- Add field to output URLs for Sitemap
- Add WP Admin Color Schemes to WPGraphQL
- List of Key Values
- Popular Posts
- Register field as a list of strings
- Register GraphQL Field with Argument
- Register object and field for custom list of users
Source
function register_graphql_field( string $type_name, string $field_name, array $config ): void {