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
- Enable and configure the same page preview for a node content type.
- Create a new node and preview it before saving.
- 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.
| Comment | File | Size | Author |
|---|---|---|---|
| preview_with_new_nodes_graphql.patch | 614 bytes | britt.vdl |
Issue fork graphql-3523332
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 #2
kingdutchWe should use `isNew` which achieves the same but has a clearer intention. Moving version to latest version.
Comment #4
kingdutchComment #5
klausiThanks, approach looks good to me. Please add a test case.
Comment #6
kingdutchComment #7
kingdutch