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

  1. Create 2 node types: article and blog_post.
  2. Expose only the article bundle to a GraphQL endpoint.
  3. Add a reference field that can reference any node type.
  4. Create an article that references a blog post.
  5. 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.

Command icon 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

pfrenssen created an issue. See original summary.

pfrenssen’s picture

Status: Active » Needs review
czigor’s picture

I'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?

czigor’s picture

Status: Needs review » Reviewed & tested by the community

Discussed 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.

pfrenssen’s picture

Thanks! Fixed the remark. Set to auto-merge.

  • pfrenssen committed 6aace8fc on 1.0.x
    [#3555012] fix: Error when an unexposed bundle is referenced
    
    By:...
pfrenssen’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.