Skip to content
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

Update useLazyQuery with planned breaking changes #12367

Open
wants to merge 207 commits into
base: release-4.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
207 commits
Select commit Hold shift + click to select a range
87143e9
Flatten LazyQueryHookOptions type and move inline
jerelmiller Feb 11, 2025
944b377
Flatten LazyQueryHookExecOptions
jerelmiller Feb 11, 2025
676ae30
Remove deprecated QueryTuple type
jerelmiller Feb 11, 2025
b4102ed
Remove deprecated LazyQueryResult type
jerelmiller Feb 11, 2025
fefe8eb
Remove deprecated QueryLazyOptions type
jerelmiller Feb 11, 2025
23182c8
Move LazyQueryResultTuple type inline
jerelmiller Feb 11, 2025
ac7639f
Move LazyQueryExecFunction inline
jerelmiller Feb 11, 2025
933d241
remove Partial from LazyQueryExecFunction
jerelmiller Feb 11, 2025
e62e439
Remove old import
jerelmiller Feb 11, 2025
f521c05
Remove variables option from hook
jerelmiller Feb 11, 2025
dd583a6
Remove defaultOptions from types
jerelmiller Feb 11, 2025
35b453b
Update test to remove variables from hook options
jerelmiller Feb 11, 2025
370e6f4
Remove duplicate test for variables passed to execute
jerelmiller Feb 11, 2025
f55b95c
Add todo comment and skip test
jerelmiller Feb 11, 2025
a17cad3
Remove variables option and defaultOptions to useLazyQuery
jerelmiller Feb 11, 2025
e1a50be
Remove outdated test
jerelmiller Feb 11, 2025
4a8a686
Remove variables option from another test
jerelmiller Feb 11, 2025
cdecc24
Add todo comment
jerelmiller Feb 11, 2025
3ad246d
Pass variables to execute function
jerelmiller Feb 11, 2025
0617c16
Move renders around to better show off behavior
jerelmiller Feb 11, 2025
0782cf6
Update option used to test stability
jerelmiller Feb 11, 2025
557d32f
Remove test for defaultOptions
jerelmiller Feb 11, 2025
d85d447
Update type test
jerelmiller Feb 11, 2025
f1548ee
Inline logic to get default fetch policy
jerelmiller Feb 11, 2025
7152db9
Remove initialFetchPolicy from options
jerelmiller Feb 11, 2025
402d183
Remove most options from LazyQueryExecFunction
jerelmiller Feb 11, 2025
bce6a6c
Remove document variable in favor of query
jerelmiller Feb 11, 2025
aed5efa
Update test for changing queries to expected new behavior
jerelmiller Feb 11, 2025
52b1aee
Copy implementation of useQuery
jerelmiller Feb 11, 2025
fe4c31b
Add check for resolved value from promise in test
jerelmiller Feb 11, 2025
8197cd5
Add assertion on promise in test
jerelmiller Feb 11, 2025
1f061b2
Move assertion up
jerelmiller Feb 11, 2025
ebc48da
Check result of promise in test
jerelmiller Feb 11, 2025
cec0d95
Check result of promise in test
jerelmiller Feb 11, 2025
c29f091
Check result of promise in test
jerelmiller Feb 11, 2025
33d4169
Add todo comment
jerelmiller Feb 11, 2025
af21fda
Add check for promise in test
jerelmiller Feb 11, 2025
73870ba
Check result of promise in test
jerelmiller Feb 11, 2025
1c4ac9c
Remove duplicate test
jerelmiller Feb 11, 2025
b0cf680
Add todo comments
jerelmiller Feb 11, 2025
1d9ed7e
Reorganize test slightly
jerelmiller Feb 11, 2025
5d71d25
Inline checks for network errors
jerelmiller Feb 11, 2025
e58569d
Add test for changing clients
jerelmiller Feb 11, 2025
2c2e15d
Add test for changing variables with cache updates
jerelmiller Feb 11, 2025
9288667
Add test for checking cached result
jerelmiller Feb 11, 2025
4208c02
Add test to check changing error policies
jerelmiller Feb 11, 2025
e302499
Add test to check for changing context
jerelmiller Feb 11, 2025
dabc788
Add test to check for changing refetchWritePolicy
jerelmiller Feb 11, 2025
66245cc
Add test to check changing returnPartialData
jerelmiller Feb 11, 2025
f05fe7d
Add test to check changing fetchPolicy
jerelmiller Feb 11, 2025
244b727
Remove unused import
jerelmiller Feb 11, 2025
e4409a6
Skip all but first test
jerelmiller Feb 11, 2025
4d65a0d
Remove code to get fetch policy from executeOptions
jerelmiller Feb 11, 2025
000b770
Change type passed to useCallback
jerelmiller Feb 11, 2025
e314b59
Create new LazyQueryResult type and use in useLazyQuery
jerelmiller Feb 11, 2025
de14bc4
Inline ObservableQueryFields
jerelmiller Feb 11, 2025
02fcb42
Add todo tests for throwing before execute function is called
jerelmiller Feb 11, 2025
5a069c8
Add a toEqualLazyQueryResult matcher
jerelmiller Feb 11, 2025
0962672
Use toEqualLazyQueryResult in useLazyQuery tests
jerelmiller Feb 11, 2025
24b43d7
Make type of observable undefined
jerelmiller Feb 11, 2025
4f7e3c7
Check that observable is undefined, then defined
jerelmiller Feb 11, 2025
f62ffc8
Expect undefined variables and no error property on initial result
jerelmiller Feb 11, 2025
2e6d551
First pass at getting results from useLazyQuery
jerelmiller Feb 11, 2025
5199de7
Don't set options yet
jerelmiller Feb 11, 2025
0d981ea
Always set observable. Ensure fetchPolicy is properly set
jerelmiller Feb 11, 2025
bd9b474
Add additional fields to returned promise
jerelmiller Feb 11, 2025
8d91312
Return client and observable in promise result
jerelmiller Feb 11, 2025
b8bb50b
Add todo comment
jerelmiller Feb 11, 2025
ea8c368
Revert check on variables and observable in test
jerelmiller Feb 11, 2025
2d7952f
Rerender when setting initial result
jerelmiller Feb 11, 2025
d25f431
Remove unneeded refs
jerelmiller Feb 11, 2025
fec54de
Set previous when changing results
jerelmiller Feb 11, 2025
0832d62
Enable more passing tests
jerelmiller Feb 11, 2025
1da6a27
Remove unneeded ?
jerelmiller Feb 11, 2025
975ac26
Check options.fetchPolicy first
jerelmiller Feb 11, 2025
debeeb0
Change order of execution
jerelmiller Feb 11, 2025
5b72b73
Enable another test
jerelmiller Feb 11, 2025
2b9d723
Add todo comment
jerelmiller Feb 11, 2025
8fb881f
Only set previousData if there was data
jerelmiller Feb 11, 2025
a7b5d72
Handle changing queries
jerelmiller Feb 11, 2025
4e9637b
Handle multiple executions of useLazyQuery
jerelmiller Feb 11, 2025
1478ce2
Remove unused import
jerelmiller Feb 11, 2025
6344572
Handle refetch
jerelmiller Feb 11, 2025
7f4251c
Update todo comment
jerelmiller Feb 11, 2025
e1ed07d
Add todo comment
jerelmiller Feb 11, 2025
1df9d7d
Handle changing variables
jerelmiller Feb 11, 2025
22788cf
Add todo comment
jerelmiller Feb 11, 2025
741bfc1
Enable another test
jerelmiller Feb 11, 2025
e9feb64
Add todo comment
jerelmiller Feb 11, 2025
b7a1887
Switch to await
jerelmiller Feb 11, 2025
d39a50b
Check result of promise in test
jerelmiller Feb 11, 2025
8cea67b
Update expected behavior in test
jerelmiller Feb 11, 2025
244b349
Update test description
jerelmiller Feb 11, 2025
695d31b
Add error handling to useLazyQuery
jerelmiller Feb 11, 2025
ade8c2c
Add todo comment
jerelmiller Feb 11, 2025
10d3ac4
Add todo comment
jerelmiller Feb 11, 2025
9605fee
Allow in flight promise to resolve when calling execute
jerelmiller Feb 11, 2025
2fdcc10
Enable more tests
jerelmiller Feb 11, 2025
0068408
Enable another test
jerelmiller Feb 11, 2025
133a541
Remove error from checked initial value
jerelmiller Feb 11, 2025
1241e59
Update test on expected behavior for network error
jerelmiller Feb 11, 2025
c68c37c
Update test on expected behavior for network error
jerelmiller Feb 11, 2025
fe8e371
Update test on expected behavior for network error
jerelmiller Feb 11, 2025
81278d8
Update expected behavior for clearStore
jerelmiller Feb 11, 2025
076f80a
Handle masking
jerelmiller Feb 11, 2025
a8b0be2
Enable masking tests
jerelmiller Feb 11, 2025
5952075
Handle changing clients
jerelmiller Feb 11, 2025
f8ce897
Fix some incorrect assertions
jerelmiller Feb 11, 2025
1cb1bbc
Enable another test
jerelmiller Feb 11, 2025
cbaa0b0
Fix some assertions
jerelmiller Feb 11, 2025
e0d9b03
Add some delay on emitted value
jerelmiller Feb 11, 2025
a4d0425
temp comment out error handling for changed error policy
jerelmiller Feb 11, 2025
a784ac2
Fix some assertions and use network-only to check context changes
jerelmiller Feb 11, 2025
b110e68
Handle changing errorPolicy and context
jerelmiller Feb 11, 2025
c84a9be
Minor tweak to test to check for context change on refetch
jerelmiller Feb 11, 2025
a785dcf
Fix some assertions and ensure refetchWritePolicy is honored
jerelmiller Feb 11, 2025
d1d6303
Fix some assertions
jerelmiller Feb 11, 2025
b29c8c7
Handle partial data changing between renders
jerelmiller Feb 11, 2025
eb625f7
Fix some assertions
jerelmiller Feb 11, 2025
64022bd
Don't set data to undefined when changing queries
jerelmiller Feb 11, 2025
9022b4b
Combine conditionals
jerelmiller Feb 11, 2025
35eb982
Remove unused copied code
jerelmiller Feb 11, 2025
34b53c7
Remove special handling of observable query methods
jerelmiller Feb 11, 2025
cbbca59
Stop exporting private functions from useQuery
jerelmiller Feb 11, 2025
c67e0cc
Return an ApolloQueryResult from the execute function
jerelmiller Feb 11, 2025
70274f7
Remove test
jerelmiller Feb 11, 2025
125e0d5
Remove unused variable
jerelmiller Feb 11, 2025
8114601
Add check for no additional renders where necessary
jerelmiller Feb 12, 2025
6ee6018
Add todo comment
jerelmiller Feb 12, 2025
90e65cb
Add test for notifyOnNetworkStatusChange
jerelmiller Feb 12, 2025
44ef2fa
Add test for network-only with notifyOnNetworkStatusChange
jerelmiller Feb 12, 2025
b28486c
Add todo comment
jerelmiller Feb 12, 2025
25ca3f5
Change test description
jerelmiller Feb 12, 2025
3a2bb6a
Add test for changing queries with notifyOnNetworkStatusChange
jerelmiller Feb 12, 2025
f7452d3
Add test for changing variables with notifyOnNetworkStatusChange
jerelmiller Feb 12, 2025
c27624d
Add test for multiple execution with cache-and-network fetch policy
jerelmiller Feb 12, 2025
7debdb1
Add test for cache-and-network when changing variables
jerelmiller Feb 12, 2025
7f2582d
Add test for cache-and-network with notifyOnNetworkStatusChange
jerelmiller Feb 12, 2025
6d5d7d1
Remove test covered by other tests
jerelmiller Feb 12, 2025
3bbb248
Change test description
jerelmiller Feb 12, 2025
b7c365f
Don't render loading states unless notifyOnNetworkStatusChange is true
jerelmiller Feb 12, 2025
a7a4bce
Handle changes for notifyOnNetworkStatusChange
jerelmiller Feb 12, 2025
bfa6722
Only update previousData if `data` changes
jerelmiller Feb 12, 2025
b22647c
Get ssr working
jerelmiller Feb 12, 2025
f289068
Consolidate variable
jerelmiller Feb 12, 2025
0ff9316
Move ssr logic into execute function
jerelmiller Feb 12, 2025
656ecbb
Remove unused dirtyRef
jerelmiller Feb 12, 2025
8cd05aa
Add todo comment
jerelmiller Feb 12, 2025
e9102ad
Remove unneeded dependency for eagerMethods
jerelmiller Feb 12, 2025
2b240b4
Bind observable query methods inline
jerelmiller Feb 12, 2025
e1f57b1
Enable test
jerelmiller Feb 12, 2025
7092a49
Enable test for multiple calls
jerelmiller Feb 12, 2025
9ab8e9e
Add back todo
jerelmiller Feb 12, 2025
96bfcab
Set initialFetchPolicy as passed in fetchPolicy when creating the obs…
jerelmiller Feb 12, 2025
2ef460b
Better initial fetch policy
jerelmiller Feb 12, 2025
aa5b91c
Move call to force update in updateResult
jerelmiller Feb 12, 2025
dc850e0
Ensure changes to fetchPolicy take place immediately
jerelmiller Feb 12, 2025
43b8593
Add todo comment
jerelmiller Feb 12, 2025
b63c3bd
Enable test switching to cached value
jerelmiller Feb 12, 2025
e6656d3
Add test with changing variables on cached result with notifyOnNetwor…
jerelmiller Feb 12, 2025
7c3bff0
Add comment
jerelmiller Feb 12, 2025
c7c530e
Add todo comment
jerelmiller Feb 12, 2025
3b4fad1
Remove unused dependencies
jerelmiller Feb 12, 2025
169ae03
Address lint issues
jerelmiller Feb 12, 2025
0b2b70e
Fix ts issues in useQuery
jerelmiller Feb 12, 2025
5710ae6
Fix lint issue
jerelmiller Feb 12, 2025
ef94e50
Update useQuery tests that use useLazyQuery
jerelmiller Feb 12, 2025
82340cb
Remove ssr support for useLazyQuery
jerelmiller Feb 12, 2025
5981717
Throw when calling execute during render
jerelmiller Feb 12, 2025
db0d247
Remove support for reobserve in useLazyQuery
jerelmiller Feb 12, 2025
0723df0
Add more todo tests
jerelmiller Feb 12, 2025
c733349
Throw when calling query functions for query that hasn't been executed
jerelmiller Feb 12, 2025
af453c6
Remove unneeded eslint disable rule
jerelmiller Feb 12, 2025
d67a52b
Ensure `this` is set to observable
jerelmiller Feb 12, 2025
13d6215
Fix lazy query result type in useQuery tests
jerelmiller Feb 12, 2025
9769b71
Add back lint disable
jerelmiller Feb 13, 2025
8543aca
Use SubscribeToMoreFunction in useLazyQuery
jerelmiller Feb 13, 2025
8494625
Use UpdateQueryMapFn in updateQuery option
jerelmiller Feb 13, 2025
e1b15bf
Enforce variables option on execute with required variables
jerelmiller Feb 13, 2025
5e57bb0
Fix TS issue with execute function
jerelmiller Feb 13, 2025
402c3a2
Apply the query immediately rather than waiting for next execute call
jerelmiller Feb 13, 2025
0ad76aa
Throw when calling execute in a non-browser environment
jerelmiller Feb 13, 2025
fd15510
Add changesets
jerelmiller Feb 13, 2025
e0f7cf6
Add test for checking execute function resolves with errorPolicy: 'all'
jerelmiller Feb 14, 2025
45f4334
Add test for error policy ignore
jerelmiller Feb 14, 2025
29404af
Add another changeset
jerelmiller Feb 14, 2025
d5aee27
Remove some todos
jerelmiller Feb 14, 2025
c2f82c4
Rerun api report
jerelmiller Feb 14, 2025
a7a90bd
Minor tweak to changeset
jerelmiller Feb 14, 2025
95bcb3c
Remove unneeded skip on type tests
jerelmiller Feb 14, 2025
eaa59f4
Remove unused properties returned from useQueryInternals
jerelmiller Feb 14, 2025
6243045
Remove unused onQueryExecuted callback
jerelmiller Feb 14, 2025
0cd4e8d
Don't return tuple fro useInternalState
jerelmiller Feb 14, 2025
9320d6d
Move creation of obsQueryFields closer to usage
jerelmiller Feb 14, 2025
109ca40
Return result directly from useQueryInternals
jerelmiller Feb 14, 2025
7a81ae8
Tweak changeset
jerelmiller Feb 14, 2025
7c09cec
Tweak changeset on new default
jerelmiller Feb 14, 2025
5fa396c
Remove check for React 19 in test
jerelmiller Feb 14, 2025
40c8637
Update advice in changeset
jerelmiller Feb 14, 2025
b38f641
Update changeset
jerelmiller Feb 14, 2025
61f8804
Remove unneeded dependency
jerelmiller Feb 14, 2025
c63b207
Inline use of hasOwnProperty
jerelmiller Feb 14, 2025
a632f66
Simplify value of initialFetchPolicy
jerelmiller Feb 14, 2025
547dd45
Add todo comment
jerelmiller Feb 14, 2025
861e23c
Remove check for window object
jerelmiller Feb 14, 2025
4d17c2a
Only return initial result on server
jerelmiller Feb 14, 2025
5dcb2df
Move creation of result variable right before its used
jerelmiller Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 53 additions & 26 deletions .api-reports/api-report-react.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1035,28 +1035,70 @@ function isReference(obj: any): obj is Reference;
// @public (undocumented)
type IsStrictlyAny<T> = UnionToIntersection<UnionForAny<T>> extends never ? true : false;

// Warning: (ae-forgotten-export) The symbol "OnlyRequiredProperties" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export type LazyQueryExecFunction<TData, TVariables extends OperationVariables> = (options?: Partial<LazyQueryHookExecOptions<TData, TVariables>>) => Promise<QueryResult<TData, TVariables>>;
export type LazyQueryExecFunction<TData, TVariables extends OperationVariables> = (...args: [TVariables] extends [never] ? [
options?: LazyQueryHookExecOptions<TVariables>
] : Record<string, never> extends OnlyRequiredProperties<TVariables> ? [
options?: LazyQueryHookExecOptions<TVariables>
] : [options: LazyQueryHookExecOptions<TVariables>]) => Promise<ApolloQueryResult<TData>>;

// @public (undocumented)
export interface LazyQueryHookExecOptions<TData = any, TVariables extends OperationVariables = OperationVariables> extends LazyQueryHookOptions<TData, TVariables> {
// (undocumented)
query?: DocumentNode | TypedDocumentNode<TData, TVariables>;
}
export type LazyQueryHookExecOptions<TVariables extends OperationVariables = OperationVariables> = {
context?: Context;
} & VariablesOption<TVariables>;

// @public (undocumented)
export interface LazyQueryHookOptions<TData = any, TVariables extends OperationVariables = OperationVariables> extends BaseQueryOptions<TVariables, TData> {
// @internal (undocumented)
defaultOptions?: Partial<WatchQueryOptions<TVariables, TData>>;
export interface LazyQueryHookOptions<TData = any, TVariables extends OperationVariables = OperationVariables> {
// @deprecated
canonizeResults?: boolean;
client?: ApolloClient<any>;
context?: Context;
errorPolicy?: ErrorPolicy;
fetchPolicy?: WatchQueryFetchPolicy;
// Warning: (ae-forgotten-export) The symbol "NextFetchPolicyContext" needs to be exported by the entry point index.d.ts
nextFetchPolicy?: WatchQueryFetchPolicy | ((this: WatchQueryOptions<TVariables, TData>, currentFetchPolicy: WatchQueryFetchPolicy, context: NextFetchPolicyContext<TData, TVariables>) => WatchQueryFetchPolicy);
notifyOnNetworkStatusChange?: boolean;
pollInterval?: number;
// Warning: (ae-forgotten-export) The symbol "RefetchWritePolicy" needs to be exported by the entry point index.d.ts
refetchWritePolicy?: RefetchWritePolicy;
returnPartialData?: boolean;
skipPollAttempt?: () => boolean;
}

// @public @deprecated (undocumented)
export type LazyQueryResult<TData, TVariables extends OperationVariables> = QueryResult<TData, TVariables>;
// @public (undocumented)
export interface LazyQueryResult<TData, TVariables extends OperationVariables> {
called: boolean;
client: ApolloClient<any>;
data: MaybeMasked<TData> | undefined;
error?: ApolloError;
// @deprecated (undocumented)
errors?: ReadonlyArray<GraphQLFormattedError>;
fetchMore: <TFetchData = TData, TFetchVars extends OperationVariables = TVariables>(fetchMoreOptions: FetchMoreQueryOptions<TFetchVars, TFetchData> & {
updateQuery?: (previousQueryResult: Unmasked<TData>, options: {
fetchMoreResult: Unmasked<TFetchData>;
variables: TFetchVars;
}) => Unmasked<TData>;
}) => Promise<ApolloQueryResult<MaybeMasked<TFetchData>>>;
loading: boolean;
networkStatus: NetworkStatus;
observable: ObservableQuery<TData, TVariables>;
previousData?: MaybeMasked<TData>;
refetch: (variables?: Partial<TVariables>) => Promise<ApolloQueryResult<MaybeMasked<TData>>>;
startPolling: (pollInterval: number) => void;
stopPolling: () => void;
// Warning: (ae-forgotten-export) The symbol "SubscribeToMoreFunction" needs to be exported by the entry point index.d.ts
subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;
// Warning: (ae-forgotten-export) The symbol "UpdateQueryMapFn" needs to be exported by the entry point index.d.ts
updateQuery: (mapFn: UpdateQueryMapFn<TData, TVariables>) => void;
variables: TVariables | undefined;
}

// @public (undocumented)
export type LazyQueryResultTuple<TData, TVariables extends OperationVariables> = [
execute: LazyQueryExecFunction<TData, TVariables>,
result: QueryResult<TData, TVariables>
result: LazyQueryResult<TData, TVariables>
];

// @public (undocumented)
Expand All @@ -1071,13 +1113,10 @@ export interface LoadableQueryHookOptions {
errorPolicy?: ErrorPolicy;
fetchPolicy?: LoadableQueryHookFetchPolicy;
queryKey?: string | number | any[];
// Warning: (ae-forgotten-export) The symbol "RefetchWritePolicy" needs to be exported by the entry point index.d.ts
refetchWritePolicy?: RefetchWritePolicy;
returnPartialData?: boolean;
}

// Warning: (ae-forgotten-export) The symbol "OnlyRequiredProperties" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export type LoadQueryFunction<TVariables extends OperationVariables> = (...args: [TVariables] extends [never] ? [] : {} extends OnlyRequiredProperties<TVariables> ? [variables?: TVariables] : [variables: TVariables]) => void;

Expand Down Expand Up @@ -1433,7 +1472,6 @@ class ObservableQuery<TData = any, TVariables extends OperationVariables = Opera
stopPolling(): void;
// Warning: (ae-forgotten-export) The symbol "SubscribeToMoreOptions" needs to be exported by the entry point index.d.ts
subscribeToMore<TSubscriptionData = TData, TSubscriptionVariables extends OperationVariables = TVariables>(options: SubscribeToMoreOptions<TData, TSubscriptionVariables, TSubscriptionData, TVariables>): () => void;
// Warning: (ae-forgotten-export) The symbol "UpdateQueryMapFn" needs to be exported by the entry point index.d.ts
updateQuery(mapFn: UpdateQueryMapFn<TData, TVariables>): void;
get variables(): TVariables | undefined;
}
Expand All @@ -1451,7 +1489,6 @@ export interface ObservableQueryFields<TData, TVariables extends OperationVariab
reobserve: (newOptions?: Partial<WatchQueryOptions<TVariables, TData>>, newNetworkStatus?: NetworkStatus) => Promise<ApolloQueryResult<MaybeMasked<TData>>>;
startPolling: (pollInterval: number) => void;
stopPolling: () => void;
// Warning: (ae-forgotten-export) The symbol "SubscribeToMoreFunction" needs to be exported by the entry point index.d.ts
subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;
updateQuery: (mapFn: UpdateQueryMapFn<TData, TVariables>) => void;
variables: TVariables | undefined;
Expand Down Expand Up @@ -1658,12 +1695,6 @@ class QueryInfo {
variables?: Record<string, any>;
}

// @public @deprecated (undocumented)
export interface QueryLazyOptions<TVariables> {
context?: Context;
variables?: TVariables;
}

// @public (undocumented)
type QueryListener = (queryInfo: QueryInfo) => void;

Expand Down Expand Up @@ -1863,9 +1894,6 @@ export interface QueryResult<TData = any, TVariables extends OperationVariables
// @public (undocumented)
type QueryStoreValue = Pick<QueryInfo, "variables" | "networkStatus" | "networkError" | "graphQLErrors">;

// @public @deprecated (undocumented)
export type QueryTuple<TData, TVariables extends OperationVariables> = LazyQueryResultTuple<TData, TVariables>;

// @public (undocumented)
type ReactiveListener<T> = (value: T) => any;

Expand Down Expand Up @@ -2029,7 +2057,6 @@ interface SharedWatchQueryOptions<TVariables extends OperationVariables, TData>
errorPolicy?: ErrorPolicy;
fetchPolicy?: WatchQueryFetchPolicy;
initialFetchPolicy?: WatchQueryFetchPolicy;
// Warning: (ae-forgotten-export) The symbol "NextFetchPolicyContext" needs to be exported by the entry point index.d.ts
nextFetchPolicy?: WatchQueryFetchPolicy | ((this: WatchQueryOptions<TVariables, TData>, currentFetchPolicy: WatchQueryFetchPolicy, context: NextFetchPolicyContext<TData, TVariables>) => WatchQueryFetchPolicy);
notifyOnNetworkStatusChange?: boolean;
pollInterval?: number;
Expand Down
84 changes: 58 additions & 26 deletions .api-reports/api-report-react_hooks.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -977,34 +977,72 @@ function isReference(obj: any): obj is Reference;
// @public (undocumented)
type IsStrictlyAny<T> = UnionToIntersection<UnionForAny<T>> extends never ? true : false;

// Warning: (ae-forgotten-export) The symbol "LazyQueryHookExecOptions" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "QueryResult" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "OnlyRequiredProperties" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type LazyQueryExecFunction<TData, TVariables extends OperationVariables> = (options?: Partial<LazyQueryHookExecOptions<TData, TVariables>>) => Promise<QueryResult<TData, TVariables>>;
export type LazyQueryExecFunction<TData, TVariables extends OperationVariables> = (...args: [TVariables] extends [never] ? [
options?: LazyQueryHookExecOptions<TVariables>
] : Record<string, never> extends OnlyRequiredProperties<TVariables> ? [
options?: LazyQueryHookExecOptions<TVariables>
] : [options: LazyQueryHookExecOptions<TVariables>]) => Promise<ApolloQueryResult<TData>>;

// Warning: (ae-forgotten-export) The symbol "LazyQueryHookOptions" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "VariablesOption" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
interface LazyQueryHookExecOptions<TData = any, TVariables extends OperationVariables = OperationVariables> extends LazyQueryHookOptions<TData, TVariables> {
// (undocumented)
query?: DocumentNode | TypedDocumentNode<TData, TVariables>;
export type LazyQueryHookExecOptions<TVariables extends OperationVariables = OperationVariables> = {
context?: DefaultContext;
} & VariablesOption<TVariables>;

// @public (undocumented)
export interface LazyQueryHookOptions<TData = any, TVariables extends OperationVariables = OperationVariables> {
// @deprecated
canonizeResults?: boolean;
client?: ApolloClient<any>;
context?: DefaultContext;
errorPolicy?: ErrorPolicy;
fetchPolicy?: WatchQueryFetchPolicy;
// Warning: (ae-forgotten-export) The symbol "NextFetchPolicyContext" needs to be exported by the entry point index.d.ts
nextFetchPolicy?: WatchQueryFetchPolicy | ((this: WatchQueryOptions<TVariables, TData>, currentFetchPolicy: WatchQueryFetchPolicy, context: NextFetchPolicyContext<TData, TVariables>) => WatchQueryFetchPolicy);
notifyOnNetworkStatusChange?: boolean;
pollInterval?: number;
// Warning: (ae-forgotten-export) The symbol "RefetchWritePolicy" needs to be exported by the entry point index.d.ts
refetchWritePolicy?: RefetchWritePolicy;
returnPartialData?: boolean;
skipPollAttempt?: () => boolean;
}

// Warning: (ae-forgotten-export) The symbol "BaseQueryOptions" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
interface LazyQueryHookOptions<TData = any, TVariables extends OperationVariables = OperationVariables> extends BaseQueryOptions<TVariables, TData> {
// @internal (undocumented)
defaultOptions?: Partial<WatchQueryOptions<TVariables, TData>>;
export interface LazyQueryResult<TData, TVariables extends OperationVariables> {
called: boolean;
client: ApolloClient<any>;
data: MaybeMasked<TData> | undefined;
error?: ApolloError;
// @deprecated (undocumented)
errors?: ReadonlyArray<GraphQLFormattedError>;
fetchMore: <TFetchData = TData, TFetchVars extends OperationVariables = TVariables>(fetchMoreOptions: FetchMoreQueryOptions<TFetchVars, TFetchData> & {
updateQuery?: (previousQueryResult: Unmasked<TData>, options: {
fetchMoreResult: Unmasked<TFetchData>;
variables: TFetchVars;
}) => Unmasked<TData>;
}) => Promise<ApolloQueryResult<MaybeMasked<TFetchData>>>;
loading: boolean;
networkStatus: NetworkStatus;
observable: ObservableQuery<TData, TVariables>;
previousData?: MaybeMasked<TData>;
refetch: (variables?: Partial<TVariables>) => Promise<ApolloQueryResult<MaybeMasked<TData>>>;
startPolling: (pollInterval: number) => void;
stopPolling: () => void;
// Warning: (ae-forgotten-export) The symbol "SubscribeToMoreFunction" needs to be exported by the entry point index.d.ts
subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;
// Warning: (ae-forgotten-export) The symbol "UpdateQueryMapFn" needs to be exported by the entry point index.d.ts
updateQuery: (mapFn: UpdateQueryMapFn<TData, TVariables>) => void;
variables: TVariables | undefined;
}

// Warning: (ae-forgotten-export) The symbol "LazyQueryExecFunction" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
type LazyQueryResultTuple<TData, TVariables extends OperationVariables> = [
export type LazyQueryResultTuple<TData, TVariables extends OperationVariables> = [
execute: LazyQueryExecFunction<TData, TVariables>,
result: QueryResult<TData, TVariables>
result: LazyQueryResult<TData, TVariables>
];

// @public (undocumented)
Expand All @@ -1020,13 +1058,10 @@ interface LoadableQueryHookOptions {
// Warning: (ae-forgotten-export) The symbol "LoadableQueryHookFetchPolicy" needs to be exported by the entry point index.d.ts
fetchPolicy?: LoadableQueryHookFetchPolicy;
queryKey?: string | number | any[];
// Warning: (ae-forgotten-export) The symbol "RefetchWritePolicy" needs to be exported by the entry point index.d.ts
refetchWritePolicy?: RefetchWritePolicy;
returnPartialData?: boolean;
}

// Warning: (ae-forgotten-export) The symbol "OnlyRequiredProperties" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export type LoadQueryFunction<TVariables extends OperationVariables> = (...args: [TVariables] extends [never] ? [] : {} extends OnlyRequiredProperties<TVariables> ? [variables?: TVariables] : [variables: TVariables]) => void;

Expand Down Expand Up @@ -1377,7 +1412,6 @@ class ObservableQuery<TData = any, TVariables extends OperationVariables = Opera
stopPolling(): void;
// Warning: (ae-forgotten-export) The symbol "SubscribeToMoreOptions" needs to be exported by the entry point index.d.ts
subscribeToMore<TSubscriptionData = TData, TSubscriptionVariables extends OperationVariables = TVariables>(options: SubscribeToMoreOptions<TData, TSubscriptionVariables, TSubscriptionData, TVariables>): () => void;
// Warning: (ae-forgotten-export) The symbol "UpdateQueryMapFn" needs to be exported by the entry point index.d.ts
updateQuery(mapFn: UpdateQueryMapFn<TData, TVariables>): void;
get variables(): TVariables | undefined;
}
Expand All @@ -1395,7 +1429,6 @@ interface ObservableQueryFields<TData, TVariables extends OperationVariables> {
reobserve: (newOptions?: Partial<WatchQueryOptions<TVariables, TData>>, newNetworkStatus?: NetworkStatus) => Promise<ApolloQueryResult<MaybeMasked<TData>>>;
startPolling: (pollInterval: number) => void;
stopPolling: () => void;
// Warning: (ae-forgotten-export) The symbol "SubscribeToMoreFunction" needs to be exported by the entry point index.d.ts
subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;
updateQuery: (mapFn: UpdateQueryMapFn<TData, TVariables>) => void;
variables: TVariables | undefined;
Expand Down Expand Up @@ -1463,6 +1496,8 @@ type Primitive = null | undefined | string | number | boolean | symbol | bigint;
// @public (undocumented)
const QUERY_REF_BRAND: unique symbol;

// Warning: (ae-forgotten-export) The symbol "BaseQueryOptions" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
interface QueryFunctionOptions<TData = any, TVariables extends OperationVariables = OperationVariables> extends BaseQueryOptions<TVariables, TData> {
// @internal (undocumented)
Expand Down Expand Up @@ -1870,7 +1905,6 @@ interface SharedWatchQueryOptions<TVariables extends OperationVariables, TData>
errorPolicy?: ErrorPolicy;
fetchPolicy?: WatchQueryFetchPolicy;
initialFetchPolicy?: WatchQueryFetchPolicy;
// Warning: (ae-forgotten-export) The symbol "NextFetchPolicyContext" needs to be exported by the entry point index.d.ts
nextFetchPolicy?: WatchQueryFetchPolicy | ((this: WatchQueryOptions<TVariables, TData>, currentFetchPolicy: WatchQueryFetchPolicy, context: NextFetchPolicyContext<TData, TVariables>) => WatchQueryFetchPolicy);
notifyOnNetworkStatusChange?: boolean;
pollInterval?: number;
Expand Down Expand Up @@ -2187,8 +2221,6 @@ export type UseFragmentResult<TData> = {
missing?: MissingTree;
};

// Warning: (ae-forgotten-export) The symbol "LazyQueryResultTuple" needs to be exported by the entry point index.d.ts
//
// @public
export function useLazyQuery<TData = any, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: LazyQueryHookOptions<NoInfer_2<TData>, NoInfer_2<TVariables>>): LazyQueryResultTuple<TData, TVariables>;

Expand Down Expand Up @@ -2234,6 +2266,8 @@ handlers: {
// @public
export function useMutation<TData = any, TVariables = OperationVariables, TContext = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>>(mutation: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: MutationHookOptions<NoInfer_2<TData>, NoInfer_2<TVariables>, TContext, TCache>): MutationTuple<TData, TVariables, TContext, TCache>;

// Warning: (ae-forgotten-export) The symbol "QueryResult" needs to be exported by the entry point index.d.ts
//
// @public
export function useQuery<TData = any, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: QueryHookOptions<NoInfer_2<TData>, NoInfer_2<TVariables>>): QueryResult<TData, TVariables>;

Expand Down Expand Up @@ -2291,8 +2325,6 @@ export function useSuspenseFragment<TData, TVariables extends OperationVariables
// @public (undocumented)
export function useSuspenseFragment<TData, TVariables extends OperationVariables = OperationVariables>(options: UseSuspenseFragmentOptions<TData, TVariables>): UseSuspenseFragmentResult<TData>;

// Warning: (ae-forgotten-export) The symbol "VariablesOption" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export type UseSuspenseFragmentOptions<TData, TVariables extends OperationVariables> = {
fragment: DocumentNode | TypedDocumentNode<TData, TVariables>;
Expand Down
5 changes: 5 additions & 0 deletions .changeset/light-dolphins-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": major
---

`useLazyQuery` no longer supports SSR environments and will now throw if the execute method is run during render. If you need to run a query in an SSR environment, use `useQuery` instead.
7 changes: 7 additions & 0 deletions .changeset/lucky-hats-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@apollo/client": major
---

The execute function returned from `useLazyQuery` now only supports the `context` and `variables` options. This means that passing options supported by the hook no longer override the hook value.

To change options, rerender the component with new options. These options will take effect with the next query execution.
7 changes: 7 additions & 0 deletions .changeset/nice-waves-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@apollo/client": major
---

The result resolved from the promise returned from the exeucte function in `useLazyQuery` is now an `ApolloQueryResult` type and no longer includes all the fields returned from the `useLazyQuery` hook tuple.

If you need access to the additional properties such as `called`, `refetch`, etc. not included in `ApolloQueryResult`, read them from the hook instead.
Loading