Skip to content

fix(graphql): preserve hasMany relationship order in populated results (replacement of #17004) - #17496

Open
deepshekhardas wants to merge 1 commit into
payloadcms:mainfrom
deepshekhardas:pr-17004-fix-graphql-order
Open

fix(graphql): preserve hasMany relationship order in populated results (replacement of #17004)#17496
deepshekhardas wants to merge 1 commit into
payloadcms:mainfrom
deepshekhardas:pr-17004-fix-graphql-order

Conversation

@deepshekhardas

Copy link
Copy Markdown

Replacement of #17004 by @yashs33244. Original was CONFLICTING — rebased onto main, conflict resolved in test/graphql/int.spec.ts (merged with new nullable schema types test).

hasMany relationship and upload fields could return populated documents in
the wrong order when a single relationship to the same collection was queried
before the array field in the same request. The populate promises run in
parallel via Promise.all and pushed onto results in resolution order, so a
dataloader cache hit on a shared document settled out of input order.

Assign each populated doc to its source index instead of pushing, then filter
out the holes left by skipped entries, so the returned list always matches the
stored order regardless of which promise settles first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants