-
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
Handle changed suspense query options #11025
Merged
jerelmiller
merged 18 commits into
release-3.8
from
handle-changed-suspense-query-options
Jul 5, 2023
Merged
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
b57636d
Apply changes to `errorPolicy` between renders
jerelmiller ca75d3f
Add support for changing context between renders
jerelmiller 96b1422
Add test to handle changing canonized results between renders
jerelmiller 1d96177
Minor tweak to canonizeResults change to be more explicit about what …
jerelmiller cbe7c35
Handle changing `refetchWritePolicy` between renders
jerelmiller f1ca4cd
Add support for changing returnPartialData
jerelmiller 779cacc
Handle changing fetchPolicy
jerelmiller 764ec93
Remove unneeded option for fetchPolicy on unrelated test
jerelmiller 924fed2
Use refetch to test updated fetch policy
jerelmiller c055e0e
Add test to ensure changing variables with other options works fine
jerelmiller ed62766
Refactor handling of `skip` in `applyOptions`.
jerelmiller ab62fbc
Minor tweak to comment
jerelmiller 878f42d
Add ability to change options between renders in useBackgroundQuery
jerelmiller a4d2482
Add changeset
jerelmiller 4566c74
Fix whitespace issue
jerelmiller 73ac2cf
Update size limit
jerelmiller aee87fd
Merge remote-tracking branch 'origin/release-3.8' into handle-changed…
jerelmiller 5fc6f03
Update size limit
jerelmiller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@apollo/client': patch | ||
--- | ||
|
||
`useSuspenseQuery` and `useBackgroundQuery` will now properly apply changes to its options between renders. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This would also trigger if the user manually sets a
fetchPolicy
of"standby"
and changes away from that. Is this really the intended behaviour in that case?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 have a validation in the hook that ensures users can't set
standby
directly:apollo-client/src/react/hooks/useSuspenseQuery.ts
Lines 265 to 280 in e47cfd0
Agreed though its not super apparent looking at this directly (which means we have an implicit dependency here). But even if we let that be the case (something I've considered), I would agree this should still the same behavior. "standby" is like a "wait to fetch" fetch policy, so we'd want to execute a request as soon as the user switches away from it. In this way,
standby
is likeskip: true
(which is exactly howskip
is implemented!).