Fix GraphQL error when duplicating M2A items with same name fields of conflicting types.#26367
Merged
AlexGaillard merged 10 commits intodirectus:mainfrom Jan 14, 2026
Merged
Conversation
gaetansenn
requested changes
Dec 16, 2025
ba52f20 to
05c8976
Compare
gaetansenn
requested changes
Dec 17, 2025
gaetansenn
requested changes
Dec 18, 2025
2800b73 to
6f73816
Compare
formfcw
previously requested changes
Dec 19, 2025
gaetansenn
requested changes
Dec 19, 2025
app/src/composables/use-item/lib/get-graphql-query-fields.test.ts
Outdated
Show resolved
Hide resolved
app/src/composables/use-item/lib/get-graphql-query-fields.test.ts
Outdated
Show resolved
Hide resolved
app/src/composables/use-item/lib/get-graphql-query-fields.test.ts
Outdated
Show resolved
Hide resolved
…h M2A fields (directus#25476) Use field aliases in GraphQL queries for M2A inline fragments to prevent conflicts when different collections have fields with the same name but different types. The aliased response data is transformed back to original field names before creating the duplicated item.
65f3e56 to
6a23acc
Compare
Co-authored-by: judda <[email protected]>
Co-authored-by: judda <[email protected]>
gaetansenn
approved these changes
Jan 13, 2026
Contributor
gaetansenn
left a comment
There was a problem hiding this comment.
LGTM ! Thank you for the great work you did on this PR ❤️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scope
What's changed:
getGraphqlQueryFieldsto return aliased field names for M2A inline fragments, preventing GraphQL validation errors when collections have fields with the same name but different typestransformM2AAliaseshelper function to transform aliased response data back to original field namessaveAsCopyto use the new alias mapping and transformationPotential Risks / Drawbacks
child1__itemsinstead ofitems), but this is transparent to users as the response is transformed back before useTested Scenarios
child1__items: items)Review Notes / Questions
__aliasForproperty fromjson-to-graphql-queryto generate field aliases in inline fragmentsChecklist
Fixes #25476