-
-
Notifications
You must be signed in to change notification settings - Fork 814
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
fix(federation): merge the elements if the shared root field is a list #6238
Conversation
🦋 Changeset detectedLatest commit: 3e5ddc0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🚀 Snapshot Release (
|
Package | Version | Info |
---|---|---|
@graphql-tools/federation |
2.0.1-alpha-20240604141848-3e5ddc0bed3db3f0d65611cf4de65e9f38fcb7dd |
npm ↗︎ unpkg ↗︎ |
@graphql-tools/utils |
10.2.2-alpha-20240604141848-3e5ddc0bed3db3f0d65611cf4de65e9f38fcb7dd |
npm ↗︎ unpkg ↗︎ |
✅ Benchmark Results
|
💻 Website PreviewThe latest changes are available as preview in: https://075df62f.graphql-tools.pages.dev |
packages/utils/src/mergeDeep.ts
Outdated
const allArrays = sources.every( | ||
source => Array.isArray(source) && source.length === target.length, | ||
); | ||
if (allArrays) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't do anything if they don't all have the same length ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put it behind the flag. So it depends. If they are arrays but not in the same length or respectArrayLength flag is disabled, the array is concatenated.
}); | ||
|
||
if (areArraysInTheSameLength) { | ||
return new Array(expectedLength).fill(null).map((_, index) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why creating a new Array ? We could just map over the first source is they have all the same length ? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TypeScript fun :D When I do sources[0]
, it doesn't see it as an array so I have to cast it
Merge the elements of the lists if the root field is shared across different subgraphs