-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Refactor] Move tracking of networkStatus
into ObservableQuery
#12407
Conversation
🦋 Changeset detectedLatest commit: 1485c05 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
@@ -1312,7 +1312,6 @@ describe("optimistic mutation results", () => { | |||
}); | |||
|
|||
it("will handle dependent updates", async () => { | |||
expect.assertions(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is not an assertion hidden in a callback so there is no way the assertion will be missed. This was fairly useless so I removed it.
commit: |
@@ -284,7 +284,7 @@ describe("ObservableQuery", () => { | |||
await expect(stream).toEmitApolloQueryResult({ | |||
data: undefined, | |||
loading: true, | |||
networkStatus: NetworkStatus.setVariables, | |||
networkStatus: NetworkStatus.refetch, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should figure out if we like this change. When calling refetch
with new variables, the networkStatus would get reported as setVariables
rather than refetch
, even though refetch
was the explicitly requested networkStatus
passed to reobserve
.
I suppose it depends on whether we view the setVariables
status as more specific than refetch
in the case of changing variables via refetch
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be fine, at least it reflects better which method you called.
b7cdc81
to
3e3585f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
}); | ||
|
||
const readCache = () => queryInfo.getDiff(); | ||
|
||
const resultsFromCache = ( | ||
diff: Cache.DiffResult<TData>, | ||
networkStatus = queryInfo.networkStatus || NetworkStatus.loading | ||
networkStatus = newNetworkStatus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: investigate if this ever can cause a race condition now that this is static and doesn't track external mutations.
3e3585f
to
25a7177
Compare
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
size-limit report 📦
|
c087aa9
to
67eb2aa
Compare
networkStatus
is really only useful forObservableQuery
as all other promise-based APIs will have a finalnetworkStatus
of eitherready
orerror
. As such, the fine-grained tracking ofnetworkStatus
has been moved toObservableQuery
. This helps us reduce the reliance onQueryInfo
some more in an effort to one day eliminate it.