Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
AugustMiller opened this issue Jun 28, 2024 · 1 comment
Closed

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

AugustMiller opened this issue Jun 28, 2024 · 1 comment
Labels
bug graphql ⚙️ features related to the GraphQL API

Comments

@AugustMiller
Copy link
Contributor

AugustMiller commented Jun 28, 2024

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

@AugustMiller AugustMiller added bug graphql ⚙️ features related to the GraphQL API labels Jun 28, 2024
brandonkelly added a commit that referenced this issue Jul 2, 2024
@brandonkelly
Copy link
Member

Fixed for 5.3 (8fdd6e0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug graphql ⚙️ features related to the GraphQL API
Projects
None yet
Development

No branches or pull requests

2 participants