-
-
Notifications
You must be signed in to change notification settings - Fork 820
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(federation/stitch): avoid recursively type-merging in case of mul…
…tiple keys (#6573) * fix(federation/stitch): avoid recursively type-merging in case of multiple keys * Setup chrome * Try fixing the test
- Loading branch information
Showing
10 changed files
with
315 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
'@graphql-tools/federation': patch | ||
'@graphql-tools/delegate': patch | ||
'@graphql-tools/stitch': patch | ||
--- | ||
|
||
When there are two services like below then the following query senty, the gateway tries to fetch `id` as an extra field because it considers `id` might be needed while this is not correct. | ||
This patch avoids any extra calls, and forwards the query as is to the 2nd service. | ||
|
||
```graphql | ||
query { | ||
viewer { | ||
booksContainer(input: $input) { | ||
edges { | ||
cursor | ||
node { | ||
source { | ||
# Book(upc=) | ||
upc | ||
} | ||
} | ||
} | ||
pageInfo { | ||
endCursor | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
```graphql | ||
type Book @key(fields: "id") @key(fields: "upc") { | ||
id: ID! | ||
upc: ID! | ||
} | ||
``` | ||
|
||
```graphql | ||
type BookContainer { # the type that is used in a collection | ||
id: ID! | ||
# ... other stuff here | ||
source: Book! | ||
} | ||
|
||
type Book @key(fields: "upc") { | ||
upc: ID! | ||
} | ||
|
||
type Query { | ||
viewer: Viewer | ||
} | ||
|
||
type Viewer { | ||
booksContainer: BooksContainerResult | ||
} | ||
|
||
type BooksContainerResult { | ||
edges: [BooksContainerEdge!]! | ||
pageInfo: PageInfo! | ||
} | ||
|
||
type BooksContainerEdge { | ||
node: BookContainer! | ||
cursor: String! | ||
} | ||
|
||
type PageInfo { | ||
endCursor: String | ||
} | ||
``` |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.