Document refetchQueries caveat for skip vs skipToken#13290
Conversation
|
@copilot: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/ |
✅ Docs preview readyThe preview is ready to be viewed. View the preview File Changes 0 new, 1 changed, 0 removedBuild ID: 6513e8fb1a689734a645fe84 URL: https://www.apollographql.com/docs/deploy-preview/6513e8fb1a689734a645fe84
|
|
Co-authored-by: phryneas <4282439+phryneas@users.noreply.github.com>
refetchQueries caveat for skip vs skipToken
commit: |
|
I would like to offer a suggestion. While the text now clearly mentions the difference between This shifts the behavior of 'skip' to a more 'standby' nature. For me 'skip' means: under no circumstances execute this query, where 'standby' means something like: I don't need the result right now. Perhaps that's something for future work. |
|
There is an additional unfortunate choice of words. The sentence:
This implies that |
Here is the code in the 3.x branch: apollo-client/src/core/QueryManager.ts Lines 938 to 944 in 5c202cf And here is the code in the 4.x branch: apollo-client/src/core/QueryManager.ts Lines 691 to 693 in b9ab334 Wait... lemme reread this. Sorry, I have 30C indoors here and this is code I haven't touched in a while 😓 |
|
Ah no, rereading that and the docs, I've refreshed my memory. So what the migration docs are saying lines up with the code for me:
|
|
I'm actually calling Trying to stay cool here also 😅 |
|
The fact that it throws the warning (line 726) is a hint that it's applying a filter based on .. something? |
|
Ah, I see now. The |
Oh dang, then you can't pass in I'll bring this up internally when we next have our maintainers meeting. |
|
So we just talked about this - what you can do is this: client.refetchQueries({
include: ["queryName"],
onQueryUpdated: (observable) =>
observable.options.fetchPolicy !== "standby",
});This would give you behavior similar to v3 when using |
|
@copilot let's also mention how to get the v3 behavior where |
Co-authored-by: jerelmiller <565661+jerelmiller@users.noreply.github.com>
Added the |
|
I reworked the section entirely to explicitly call out both the Thanks again for reporting this @FritsvanCampen! |
Apollo Client 4 changed how skipped queries participate in
client.refetchQueries(), and the migration guide did not call out the remaining behavioral difference betweenskip: trueandskipToken. This left the “active/inactive queries” section incomplete for users upgrading from Apollo Client 3.Migration guide
apollo-client-4-migration.mdxskipandskipTokenput a query into standby, but they are not equivalent for explicitclient.refetchQueries({ include: [QUERY] })before first executionBehavioral caveat
skip: truequeries can still be refetched because Apollo Client already knows the query options, including variablesskipTokenqueries are excluded until first execution because no variables were provided yetExample