nodeByPath does not resolve correctly for certain content type names

Created on 6 December 2022, over 1 year ago
Updated 13 April 2023, about 1 year ago

Hi there. I may use some incorrect terminology here, as this is my first time using GraphQL. Please don't hesitate to make edits to help clarify things.

Problem/Motivation

nodeByPath does not correctly resolve content types that have their names changed when singularized, or have spaces in their names.

Steps to reproduce

  • Create a content type whose name changes when singularized using the languageInflector. Example content type name: Criteria, which gets changed to NodeCriterion
  • Create a criteria node, assign it a path of /test-criteria
  • In the graphql explorer look up the new path using nodeByPath
  • With debugging, the result will be "Abstract type NodeContentUnion must resolve to an Object type at runtime for field Query.nodeByPath with value \"instance of Drupal\\node\\Entity\\Node\", received \"null\". Either the NodeContentUnion type should provide a \"resolveType\" function or each possible type should provide an \"isTypeOf\" function."
  • This happens because the resolver in ContentTypeSchemaExtension is resolves content types of criteria to NodeCriteria instead of NodeCriterion

  • Create a content type whose machine name has an underscore. Example content type name: Landing Page (with a machine name of landing_page
  • Create a landing_page node, assign it a path of /test-landing-page
  • In the graphql explorer look up the new path using nodeByPath
  • With debugging, the result shows the same error as above
  • This happens because the resolver in ContentTypeSchemaExtension is resolves content types of landing_page to NodeLanding_page instead of NodeLandingPage

Proposed resolution

Adjust the type resolver in ContentTypeSchemaExtender to resolve the expected singular name.

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

I don't believe this causes any

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jlandfried

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024