-
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 useLazyQuery
to reuse useInternalState
and make execution function call reobserve
instead of refetch
#9564
Merged
Merged
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
7fc6c89
Improve various (passing) tests.
benjamn 3546c9c
Improve useLazyQuery-related types.
benjamn 02a1e6d
Reuse useInternalState for useLazyQuery.
benjamn a18e2e0
Avoid needlessly overriding internalState.useQuery QueryResult.
benjamn 2302716
Reuse internalState.toQueryResult for useLazyQuery execute function.
benjamn 4e77bca
Use useRef instead of useState for useLazyQuery execution state.
benjamn 72a805d
Use execOptionsRef.current to represent both options and called-ness.
benjamn f93e904
Use reobserve rather than refetch for useLazyQuery exec function.
benjamn d26bdd4
Make options parameter to applyFetchPolicy non-optional.
benjamn 52ba67e
Allow NetworkStatus.setVariables inference when fetchPolicy unchanged.
benjamn 6cb2cdb
Backup ApolloQueryResult for standby lazy executions.
benjamn ff0186d
Always mark NetworkStatus.ready after network fetch.
benjamn 4be1901
Simplify useLazyQuery initial fetchPolicy/skip options.
benjamn 71d8df4
Reject useLazyQuery execution Promise on error.
benjamn 345a156
Call internalState.forceUpdate in eager methods only if first call.
benjamn f164b1b
Use manual wrapping rather than Function.prototype.bind.
benjamn 89af070
Provide use[Lazy]Query(...).reobserve in addition to refetch.
benjamn 782642b
Revert manual wrapping of ObservableQueryMethods in favor of bind.
benjamn c3d1a83
Remove unnecessary public modifiers from InternalState methods.
benjamn da41ce8
Allow specifying WatchQueryOptions.initialFetchPolicy explicitly.
benjamn c9a2c01
Bring back exported QueryTuple type as alias for LazyQueryResultTuple.
benjamn feb07db
Make TODO comment easier to grep for.
benjamn ff43d78
Mention PR #9564 in CHANGELOG.md.
benjamn 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
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
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
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.
I don't love adding another optional field to
WatchQueryOptions
, but I truly do not expect anyone to need to use this field directly, and it helps us maintain the promise thatskip: true
is (more or less) synonymous withfetchPolicy: "standby"
, because it gives us a way to passfetchPolicy: "standby"
whenskip: true
without ending up stuck withinitialFetchPolicy === "standby"
.