Commit 2b39cc8
authored
Fix issue where changes to
Fixes #13335
We had a regression in 4.x with regards to `@export` fields where
queries would sometimes not respond to cache updates. This happened when
a field changed an object that depended on the variables keyed by the
`@export` values.
```gql
query ($userId: ID!) {
userId @client @export(as: "userId")
user(id: $userId) {
id
name
}
}
```
In this case, `ObservableQuery` subscribed to the cache using the
initial empty variables value, but never resubscribed after export
variables were known. This meant changes to data inside that `user`
object never notified the query of the change.
This fix now emits a `resolvedVariables` value along with the
notification to `ObservableQuery` so that `ObservableQuery` can update
its `variables` and resubscribe to the cache using the export variables.
I added a whole bunch of other tests to catch other potential edge cases
to make sure we didn't miss this for other situations.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Fixed reactivity issues affecting queries that use `@export`
variables.
* Cache updates now correctly trigger refreshed results when
exported-variable fields change or are evicted.
* Improved behavior for refetching, partial data, cache-and-network
requests, and network-only requests.
* Improved handling of streamed responses and variable changes during
in-flight requests.
* **Tests**
* Added coverage for cache, network, refetch, partial-result, and
streaming scenarios involving `@export` variables.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: jerelmiller <565661+jerelmiller@users.noreply.github.com>@export fields did not trigger updates (#13367)1 parent 2f383e7 commit 2b39cc8
9 files changed
Lines changed: 1291 additions & 9 deletions
File tree
- .api-reports
- .changeset
- src
- __tests__/local-state
- core
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1116 | 1116 | | |
1117 | 1117 | | |
1118 | 1118 | | |
| 1119 | + | |
1119 | 1120 | | |
1120 | 1121 | | |
1121 | 1122 | | |
1122 | 1123 | | |
| 1124 | + | |
1123 | 1125 | | |
1124 | 1126 | | |
1125 | 1127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2530 | 2530 | | |
2531 | 2531 | | |
2532 | 2532 | | |
| 2533 | + | |
2533 | 2534 | | |
2534 | 2535 | | |
2535 | 2536 | | |
2536 | 2537 | | |
| 2538 | + | |
2537 | 2539 | | |
2538 | 2540 | | |
2539 | 2541 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
6 | 6 | | |
0 commit comments