Skip to content

[5.x]: GraphQL type name collision #15269

@AugustMiller

Description

@AugustMiller

What happened?

When GraphQL mutation names are generated for nested entries and sections, a collision is possible for _Drafts.

Mutations for Matrix field entry drafts omit the Field segment, meaning they will receive the same name as the mutation for drafts in a section that shares a handle with the field.

https://github.com/craftcms/cms/blob/5.x/src/gql/mutations/Entry.php#L285

Steps to Reproduce

  1. Create an entry type named Stop (with handle stop);
  2. Create a section named Tours (with handle tours) and an entry type named Tour (with handle tour) — the naming here is immaterial and doesn’t contribute to the bug… we just need a place to stick the field, semantically;
  3. Create a Matrix field named Stops that uses the Stop entry type, and attach it to the Tour entry type’s field layout;
  4. Create a section named Stops (also with handle stops) that uses the Stop entry type;

(This last step is contrived—most developers are probably not creating deliberately ambiguous content types like this!)

The resulting GraphQL schema would produce these four mutations:

  • save_stops_stop_Entry — Save a Stop entry to the Stops section
  • save_stops_stop_Draft — Save a Stop entry draft to the Stops section
  • save_stopsField_stop_Entry — Save a nested Stop entry into the Stops Matrix field
  • save_stops_stop_Draft — Save a nested Stop entry into the Stops Matrix field

The second and third _Draft type names are the same! Currently, Craft appears to only acknowledge the latter (or… whichever one is created second?)

Craft CMS version

5.0.0+

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggraphql ⚙️features related to the GraphQL API

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions