Problem/Motivation
When an entity type does not expose all of its bundles, an error occurs if a requested entity references one of the unexposed bundles.
Steps to reproduce
- Create 2 node types: article and blog_post.
- Expose only the article bundle to a GraphQL endpoint.
- Add a reference field that can reference any node type.
- Create an article that references a blog post.
- Request the article over GraphQL, e.g. using an entity query.
The following error is thrown:
GraphQL\Error\Error: Type "NodeBlogPost" not found in document. in GraphQL\Utils\BuildSchema::GraphQL\Utils\@closure() (line 149 of /home/vcap/app/vendor/webonyx/graphql-php/src/Utils/BuildSchema.php).
Proposed resolution
Expose a dummy type NodeUnexposed that can be used to resolve unexposed node bundles.
Data model changes
All entity types that have unexposed bundles will now expose a dummy type.
Issue fork graphql_core_schema-3555012
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
pfrenssenComment #4
czigor commentedI'm not sure this is a bug. Referenced bundles should be enabled for the schema. Can there be a reason for not doing that?
What about disabled referenced entity types?
Comment #5
czigor commentedDiscussed this with Pieter. Results:
1. We might not want to expose a specific bundle if the graphql endpoint is not protected.
2. Disabled entity types might still be an issue.
A test can (and should) be added later.
So apart from the nitpick comment on the MR this is good to go on my part.
Comment #6
pfrenssenThanks! Fixed the remark. Set to auto-merge.
Comment #8
pfrenssen