Problem/Motivation

The EntityUrl DataProducer in the GraphQL module assumes that the entity passed to it is always valid and has an ID. However, in some cases (like when using the same page preview on newly created nodes), this assumption can lead to an exception.

Steps to reproduce

  1. Enable and configure the same page preview for a node content type.
  2. Create a new node and preview it before saving.
  3. Observe that the query fails with a entity malformed exception

Proposed resolution

This patch adds a safeguard to the resolve() method of EntityUrl to return null if the passed entity does not have an ID.

CommentFileSizeAuthor
preview_with_new_nodes_graphql.patch614 bytesbritt.vdl

Issue fork graphql-3523332

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

britt.vdl created an issue. See original summary.

kingdutch’s picture

Title: Preview with new nodes » EntityUrl with new entities breaks
Version: 8.x-4.10 » 5.x-dev
Status: Active » Needs work

We should use `isNew` which achieves the same but has a clearer intention. Moving version to latest version.

kingdutch’s picture

Status: Needs work » Needs review
klausi’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Thanks, approach looks good to me. Please add a test case.

kingdutch’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
kingdutch’s picture

Status: Needs review » 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.

  • kingdutch committed 0e25c192 on 5.x
    fix: #3523332 EntityUrl with new entities breaks
    

Status: Fixed » Closed (fixed)

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