Skip to content

Commit

Permalink
Provide use[Lazy]Query(...).reobserve in addition to refetch.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed Apr 4, 2022
1 parent f164b1b commit 89af070
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/react/components/__tests__/client/Query.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('Query component', () => {
observable,
fetchMore,
refetch,
reobserve,
startPolling,
stopPolling,
subscribeToMore,
Expand Down
3 changes: 2 additions & 1 deletion src/react/hooks/useLazyQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { isNonEmptyArray } from '../../utilities';
// whether the useLazyQuery execute function was called before.
const EAGER_METHODS = [
'refetch',
'reobserve',
'fetchMore',
'updateQuery',
'startPolling',
Expand Down Expand Up @@ -76,7 +77,7 @@ export function useLazyQuery<TData = any, TVariables = OperationVariables>(
const execute = useCallback<
LazyQueryResultTuple<TData, TVariables>[0]
>(executeOptions => {
const promise = result.observable.reobserve(
const promise = result.reobserve(
execOptionsRef.current = executeOptions ? {
...executeOptions,
fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy,
Expand Down
1 change: 1 addition & 0 deletions src/react/hooks/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ class InternalState<TData, TVariables> {
return {
// These methods are available directly from result.observable now.
refetch: wrap("refetch"),
reobserve: wrap("reobserve"),
fetchMore: wrap("fetchMore"),
updateQuery: wrap("updateQuery"),
startPolling: wrap("startPolling"),
Expand Down
1 change: 1 addition & 0 deletions src/react/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export type ObservableQueryFields<TData, TVariables> = Pick<
| 'subscribeToMore'
| 'updateQuery'
| 'refetch'
| 'reobserve'
| 'variables'
| 'fetchMore'
>;
Expand Down

0 comments on commit 89af070

Please sign in to comment.