Commit 74ca7dd
authored
Fix
We should never query `__typename` from a subgraph for an object type
marked `@interfaceObject`, as the value we get back will always be
wrong. Normally, we prevent this by not having a `__typename` edge in
the federated query graph.
However, during the optimization where we try to reuse existing named
fragments, we rebase them from the API schema onto the subgraph schemas.
We usually ignore selections where this leads to invalidity (e.g. fields
or types that don't exist in the subgraph schema), but the code doesn't
currently view the `__typename` field being rebased onto an interface
object as invalid. This has led to bugs where named fragments containing
`__typename` accidentally cause it to be queried on interface objects in
subgraph queries.
This PR changes `Field.rebaseOn()` such that `__typename` being rebased
onto a parent type that is an interface object is considered invalid.
Additionally, if the parent type is an abstract type, and that abstract
type could possibly be an interface object type at runtime, then this is
additionally considered invalid.__typename rebasing for interface objects (#2886)1 parent 7b5b836 commit 74ca7dd
3 files changed
Lines changed: 73 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
2798 | 2799 | | |
2799 | 2800 | | |
2800 | 2801 | | |
2801 | | - | |
| 2802 | + | |
2802 | 2803 | | |
2803 | 2804 | | |
2804 | 2805 | | |
| |||
3514 | 3515 | | |
3515 | 3516 | | |
3516 | 3517 | | |
| 3518 | + | |
| 3519 | + | |
| 3520 | + | |
| 3521 | + | |
| 3522 | + | |
| 3523 | + | |
| 3524 | + | |
| 3525 | + | |
| 3526 | + | |
| 3527 | + | |
| 3528 | + | |
| 3529 | + | |
| 3530 | + | |
| 3531 | + | |
| 3532 | + | |
| 3533 | + | |
| 3534 | + | |
| 3535 | + | |
| 3536 | + | |
| 3537 | + | |
| 3538 | + | |
| 3539 | + | |
| 3540 | + | |
| 3541 | + | |
| 3542 | + | |
| 3543 | + | |
| 3544 | + | |
| 3545 | + | |
| 3546 | + | |
| 3547 | + | |
| 3548 | + | |
| 3549 | + | |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
| 3556 | + | |
| 3557 | + | |
| 3558 | + | |
| 3559 | + | |
| 3560 | + | |
| 3561 | + | |
| 3562 | + | |
| 3563 | + | |
| 3564 | + | |
| 3565 | + | |
| 3566 | + | |
| 3567 | + | |
| 3568 | + | |
| 3569 | + | |
| 3570 | + | |
| 3571 | + | |
| 3572 | + | |
| 3573 | + | |
| 3574 | + | |
3517 | 3575 | | |
3518 | 3576 | | |
3519 | 3577 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
308 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
309 | 317 | | |
310 | 318 | | |
311 | 319 | | |
| |||
0 commit comments