Commit 2192f35
fix handling of __typename optimizations (#3156)
Fixes handling of a `__typename` selection during query planning
process.
When expanding fragments we were keeping references to the same `Field`s
regardless where those fragments appeared in our original selection set.
This was generally fine as in most cases we would have same inline
fragment selection sets across whole operation but was causing problems
when we were applying another optimization by collapsing those expanded
inline fragments creating a new selection set. As a result, if any
single field selection (within that fragment) would perform optimization
around the usage of `__typename`, ALL occurrences of that field
selection would get that optimization as well. See example below
```graphql
foo {
f1 {
... on Bar {
__typename
...onBar # will be collapsed and sub selections will optimize __typename
}
}
f2 {
...onBar # sub selections will get __typename optimization from above
}
}
fragment onBar on Bar {
b
c
}
```
---------
Co-authored-by: Sachin D. Shinde <sachin@apollographql.com>1 parent cda078c commit 2192f35
3 files changed
Lines changed: 56 additions & 26 deletions
File tree
- .changeset
- internals-js/src
- query-planner-js/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
102 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | | - | |
| 107 | + | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
173 | 184 | | |
174 | 185 | | |
175 | 186 | | |
| |||
178 | 189 | | |
179 | 190 | | |
180 | 191 | | |
181 | | - | |
| 192 | + | |
182 | 193 | | |
183 | 194 | | |
184 | 195 | | |
| |||
189 | 200 | | |
190 | 201 | | |
191 | 202 | | |
192 | | - | |
| 203 | + | |
193 | 204 | | |
194 | 205 | | |
195 | 206 | | |
| |||
200 | 211 | | |
201 | 212 | | |
202 | 213 | | |
203 | | - | |
| 214 | + | |
204 | 215 | | |
205 | 216 | | |
206 | 217 | | |
| |||
211 | 222 | | |
212 | 223 | | |
213 | 224 | | |
214 | | - | |
| 225 | + | |
215 | 226 | | |
216 | 227 | | |
217 | 228 | | |
| |||
505 | 516 | | |
506 | 517 | | |
507 | 518 | | |
508 | | - | |
| 519 | + | |
509 | 520 | | |
510 | 521 | | |
511 | 522 | | |
512 | 523 | | |
513 | 524 | | |
514 | | - | |
| 525 | + | |
515 | 526 | | |
516 | 527 | | |
517 | 528 | | |
| |||
590 | 601 | | |
591 | 602 | | |
592 | 603 | | |
593 | | - | |
| 604 | + | |
594 | 605 | | |
595 | 606 | | |
596 | 607 | | |
| |||
655 | 666 | | |
656 | 667 | | |
657 | 668 | | |
658 | | - | |
| 669 | + | |
659 | 670 | | |
660 | 671 | | |
661 | 672 | | |
| |||
3042 | 3053 | | |
3043 | 3054 | | |
3044 | 3055 | | |
| 3056 | + | |
| 3057 | + | |
| 3058 | + | |
| 3059 | + | |
| 3060 | + | |
| 3061 | + | |
3045 | 3062 | | |
3046 | 3063 | | |
3047 | 3064 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
3391 | 3392 | | |
3392 | 3393 | | |
3393 | 3394 | | |
3394 | | - | |
| 3395 | + | |
3395 | 3396 | | |
3396 | 3397 | | |
3397 | | - | |
| 3398 | + | |
3398 | 3399 | | |
3399 | 3400 | | |
3400 | 3401 | | |
| |||
3413 | 3414 | | |
3414 | 3415 | | |
3415 | 3416 | | |
| 3417 | + | |
3416 | 3418 | | |
3417 | 3419 | | |
3418 | 3420 | | |
| |||
3445 | 3447 | | |
3446 | 3448 | | |
3447 | 3449 | | |
| 3450 | + | |
| 3451 | + | |
| 3452 | + | |
3448 | 3453 | | |
3449 | 3454 | | |
3450 | 3455 | | |
| |||
3473 | 3478 | | |
3474 | 3479 | | |
3475 | 3480 | | |
3476 | | - | |
| 3481 | + | |
3477 | 3482 | | |
3478 | 3483 | | |
3479 | 3484 | | |
| |||
4328 | 4333 | | |
4329 | 4334 | | |
4330 | 4335 | | |
4331 | | - | |
| 4336 | + | |
4332 | 4337 | | |
4333 | 4338 | | |
4334 | | - | |
| 4339 | + | |
4335 | 4340 | | |
4336 | 4341 | | |
4337 | 4342 | | |
| |||
4631 | 4636 | | |
4632 | 4637 | | |
4633 | 4638 | | |
4634 | | - | |
| 4639 | + | |
4635 | 4640 | | |
4636 | 4641 | | |
4637 | 4642 | | |
4638 | 4643 | | |
4639 | | - | |
| 4644 | + | |
4640 | 4645 | | |
4641 | 4646 | | |
4642 | 4647 | | |
| |||
0 commit comments