Filter to add restricted field on Model

Labels on Post Types are not publicly exposed by WordPress. They are attributes for use in the Admin, and are treated with respect to proper access to the admin.

To see the labels, the user requesting them must be authenticated.

When a user requesting a PostType, these are the following fields that are by default allowed to be viewed by a public request:

You can use the graphql_allowed_fields_on_restricted_type filter to expose more fields publicly if you chose to do so:

add_filter( 'graphql_allowed_fields_on_restricted_type', function( $fields, $model_name, $data, $visibility, $owner, $current_user ) {
	if ( 'PostTypeObject' === $model_name ) {
		$fields[] = 'label';
	return $fields;
}, 10, 6 );

Before adding the filter:

Restricted field before adding filter

After adding the filter:

Restricted field after adding filter

Github Issue: