fix(federation): merge the elements if the shared root field is a list#6238
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 |
| const allArrays = sources.every( | ||
| source => Array.isArray(source) && source.length === target.length, | ||
| ); | ||
| if (allArrays) { |
There was a problem hiding this comment.
We don't do anything if they don't all have the same length ?
There was a problem hiding this comment.
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.
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.
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