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: https://github.com/wp-graphql/wp-graphql/blob/develop/src/Model/PostType.php#L59
You can use the graphql_allowed_fields_on_restricted_type
filter to expose more fields publicly if you chose to do so: https://github.com/wp-graphql/wp-graphql/blob/develop/src/Model/Model.php#L292
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:
After adding the filter:
Github Issue: https://github.com/wp-graphql/wp-graphql/issues/1304#issuecomment-626836656