@apollo/client 4.0.2 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/__cjs/core/ApolloClient.cjs +8 -0
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +9 -1
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +5 -0
- package/__cjs/masking/maskFragment.cjs +2 -3
- package/__cjs/masking/maskFragment.cjs.map +1 -1
- package/__cjs/react/hooks/internal/wrapHook.cjs +2 -3
- package/__cjs/react/hooks/internal/wrapHook.cjs.map +1 -1
- package/__cjs/react/hooks/internal/wrapHook.d.cts +0 -1
- package/__cjs/react/hooks/useFragment.cjs +2 -2
- package/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.cjs +4 -3
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +1 -1
- package/__cjs/react/hooks/useQuery.cjs +34 -13
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +160 -4
- package/__cjs/react/index.cjs.map +1 -1
- package/__cjs/react/index.d.cts +9 -0
- package/__cjs/react/internal/index.cjs +1 -3
- package/__cjs/react/internal/index.cjs.map +1 -1
- package/__cjs/react/internal/index.d.cts +3 -2
- package/__cjs/utilities/caching/sizes.cjs.map +1 -1
- package/__cjs/utilities/caching/sizes.d.cts +0 -11
- package/__cjs/utilities/internal/equalByQuery.cjs +3 -4
- package/__cjs/utilities/internal/equalByQuery.cjs.map +1 -1
- package/__cjs/utilities/invariant/index.cjs +3 -0
- package/__cjs/utilities/invariant/index.cjs.map +1 -1
- package/__cjs/version.cjs +1 -1
- package/core/ApolloClient.d.ts +9 -1
- package/core/ApolloClient.js +8 -0
- package/core/ApolloClient.js.map +1 -1
- package/core/index.d.ts +6 -1
- package/core/index.js.map +1 -1
- package/masking/maskFragment.js +1 -1
- package/masking/maskFragment.js.map +1 -1
- package/package.json +1 -1
- package/react/hooks/internal/wrapHook.d.ts +0 -1
- package/react/hooks/internal/wrapHook.js +1 -1
- package/react/hooks/internal/wrapHook.js.map +1 -1
- package/react/hooks/useFragment.js +1 -1
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useMutation.d.ts +1 -1
- package/react/hooks/useMutation.js +5 -4
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +160 -4
- package/react/hooks/useQuery.js +35 -14
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks-compiled/internal/wrapHook.d.ts +0 -1
- package/react/hooks-compiled/internal/wrapHook.js +1 -1
- package/react/hooks-compiled/internal/wrapHook.js.map +1 -1
- package/react/hooks-compiled/useFragment.js +1 -1
- package/react/hooks-compiled/useFragment.js.map +1 -1
- package/react/hooks-compiled/useMutation.d.ts +1 -1
- package/react/hooks-compiled/useMutation.js +3 -3
- package/react/hooks-compiled/useMutation.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +160 -4
- package/react/hooks-compiled/useQuery.js +154 -133
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/index.compiled.d.ts +9 -0
- package/react/index.compiled.js.map +1 -1
- package/react/index.d.ts +10 -1
- package/react/index.js.map +1 -1
- package/react/internal/index.d.ts +3 -2
- package/react/internal/index.js +1 -2
- package/react/internal/index.js.map +1 -1
- package/utilities/caching/sizes.d.ts +0 -11
- package/utilities/caching/sizes.js.map +1 -1
- package/utilities/internal/equalByQuery.js +1 -1
- package/utilities/internal/equalByQuery.js.map +1 -1
- package/utilities/invariant/index.js +3 -0
- package/utilities/invariant/index.js.map +1 -1
- package/version.js +1 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DataState, DefaultContext, DocumentNode, ErrorLike, ErrorPolicy, GetDataState, InternalTypes, ObservableQuery, OperationVariables, RefetchWritePolicy, SubscribeToMoreFunction, TypedDocumentNode, UpdateQueryMapFn, WatchQueryFetchPolicy } from "@apollo/client";
|
|
2
|
+
import type { ApolloClient } from "@apollo/client";
|
|
2
3
|
import { NetworkStatus } from "@apollo/client";
|
|
3
4
|
import type { MaybeMasked } from "@apollo/client/masking";
|
|
4
5
|
import type { DocumentationTypes as UtilityDocumentationTypes, NoInfer, VariablesOption } from "@apollo/client/utilities/internal";
|
|
6
|
+
import type { SkipToken } from "./constants.js";
|
|
5
7
|
export declare namespace useQuery {
|
|
6
8
|
namespace Base {
|
|
7
9
|
interface Options<TData = unknown, TVariables extends OperationVariables = OperationVariables> {
|
|
@@ -119,7 +121,7 @@ export declare namespace useQuery {
|
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
123
|
namespace Base {
|
|
122
|
-
interface Result<TData = unknown, TVariables extends OperationVariables = OperationVariables> {
|
|
124
|
+
interface Result<TData = unknown, TVariables extends OperationVariables = OperationVariables, TReturnVariables extends OperationVariables = TVariables> {
|
|
123
125
|
/**
|
|
124
126
|
* The instance of Apollo Client that executed the query.
|
|
125
127
|
* Can be useful for manually executing followup queries or writing data to the cache.
|
|
@@ -213,7 +215,7 @@ export declare namespace useQuery {
|
|
|
213
215
|
*
|
|
214
216
|
* @docGroup 1. Operation data
|
|
215
217
|
*/
|
|
216
|
-
variables:
|
|
218
|
+
variables: TReturnVariables;
|
|
217
219
|
/**
|
|
218
220
|
* A function that helps you fetch the next set of results for a [paginated list field](https://www.apollographql.com/docs/react/pagination/core-api/).
|
|
219
221
|
*
|
|
@@ -223,7 +225,7 @@ export declare namespace useQuery {
|
|
|
223
225
|
fetchMore: <TFetchData = TData, TFetchVars extends OperationVariables = TVariables>(fetchMoreOptions: ObservableQuery.FetchMoreOptions<TData, TVariables, TFetchData, TFetchVars>) => Promise<ApolloClient.QueryResult<MaybeMasked<TFetchData>>>;
|
|
224
226
|
}
|
|
225
227
|
}
|
|
226
|
-
type Result<TData = unknown, TVariables extends OperationVariables = OperationVariables, TStates extends DataState<TData>["dataState"] = DataState<TData>["dataState"]> = Base.Result<TData, TVariables> & GetDataState<MaybeMasked<TData>, TStates>;
|
|
228
|
+
type Result<TData = unknown, TVariables extends OperationVariables = OperationVariables, TStates extends DataState<TData>["dataState"] = DataState<TData>["dataState"], TReturnVariables extends OperationVariables = TVariables> = Base.Result<TData, TVariables, TReturnVariables> & GetDataState<MaybeMasked<TData>, TStates>;
|
|
227
229
|
namespace DocumentationTypes {
|
|
228
230
|
namespace useQuery {
|
|
229
231
|
interface Result<TData = unknown, TVariables extends OperationVariables = OperationVariables> extends Base.Result<TData, TVariables>, UtilityDocumentationTypes.DataState<TData> {
|
|
@@ -345,6 +347,82 @@ export declare function useQuery<TData = unknown, TVariables extends OperationVa
|
|
|
345
347
|
* @param options - Options to control how the query is executed.
|
|
346
348
|
* @returns Query result object
|
|
347
349
|
*/
|
|
350
|
+
export declare function useQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken): useQuery.Result<TData, TVariables, "empty", Record<string, never>>;
|
|
351
|
+
/**
|
|
352
|
+
* A hook for executing queries in an Apollo application.
|
|
353
|
+
*
|
|
354
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
355
|
+
*
|
|
356
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
357
|
+
*
|
|
358
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
*
|
|
362
|
+
* ```jsx
|
|
363
|
+
* import { gql } from "@apollo/client";
|
|
364
|
+
* import { useQuery } from "@apollo/client/react";
|
|
365
|
+
*
|
|
366
|
+
* const GET_GREETING = gql`
|
|
367
|
+
* query GetGreeting($language: String!) {
|
|
368
|
+
* greeting(language: $language) {
|
|
369
|
+
* message
|
|
370
|
+
* }
|
|
371
|
+
* }
|
|
372
|
+
* `;
|
|
373
|
+
*
|
|
374
|
+
* function Hello() {
|
|
375
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
376
|
+
* variables: { language: "english" },
|
|
377
|
+
* });
|
|
378
|
+
* if (loading) return <p>Loading ...</p>;
|
|
379
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
380
|
+
* }
|
|
381
|
+
* ```
|
|
382
|
+
*
|
|
383
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
384
|
+
* @param options - Options to control how the query is executed.
|
|
385
|
+
* @returns Query result object
|
|
386
|
+
*/
|
|
387
|
+
export declare function useQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
388
|
+
returnPartialData: true;
|
|
389
|
+
})): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming" | "partial", Partial<TVariables>>;
|
|
390
|
+
/**
|
|
391
|
+
* A hook for executing queries in an Apollo application.
|
|
392
|
+
*
|
|
393
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
394
|
+
*
|
|
395
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
396
|
+
*
|
|
397
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
*
|
|
401
|
+
* ```jsx
|
|
402
|
+
* import { gql } from "@apollo/client";
|
|
403
|
+
* import { useQuery } from "@apollo/client/react";
|
|
404
|
+
*
|
|
405
|
+
* const GET_GREETING = gql`
|
|
406
|
+
* query GetGreeting($language: String!) {
|
|
407
|
+
* greeting(language: $language) {
|
|
408
|
+
* message
|
|
409
|
+
* }
|
|
410
|
+
* }
|
|
411
|
+
* `;
|
|
412
|
+
*
|
|
413
|
+
* function Hello() {
|
|
414
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
415
|
+
* variables: { language: "english" },
|
|
416
|
+
* });
|
|
417
|
+
* if (loading) return <p>Loading ...</p>;
|
|
418
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
419
|
+
* }
|
|
420
|
+
* ```
|
|
421
|
+
*
|
|
422
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
423
|
+
* @param options - Options to control how the query is executed.
|
|
424
|
+
* @returns Query result object
|
|
425
|
+
*/
|
|
348
426
|
export declare function useQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
349
427
|
returnPartialData: boolean;
|
|
350
428
|
}): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming" | "partial">;
|
|
@@ -384,9 +462,87 @@ export declare function useQuery<TData = unknown, TVariables extends OperationVa
|
|
|
384
462
|
* @param options - Options to control how the query is executed.
|
|
385
463
|
* @returns Query result object
|
|
386
464
|
*/
|
|
465
|
+
export declare function useQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
466
|
+
returnPartialData: boolean;
|
|
467
|
+
})): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming" | "partial", Partial<TVariables>>;
|
|
468
|
+
/**
|
|
469
|
+
* A hook for executing queries in an Apollo application.
|
|
470
|
+
*
|
|
471
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
472
|
+
*
|
|
473
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
474
|
+
*
|
|
475
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
*
|
|
479
|
+
* ```jsx
|
|
480
|
+
* import { gql } from "@apollo/client";
|
|
481
|
+
* import { useQuery } from "@apollo/client/react";
|
|
482
|
+
*
|
|
483
|
+
* const GET_GREETING = gql`
|
|
484
|
+
* query GetGreeting($language: String!) {
|
|
485
|
+
* greeting(language: $language) {
|
|
486
|
+
* message
|
|
487
|
+
* }
|
|
488
|
+
* }
|
|
489
|
+
* `;
|
|
490
|
+
*
|
|
491
|
+
* function Hello() {
|
|
492
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
493
|
+
* variables: { language: "english" },
|
|
494
|
+
* });
|
|
495
|
+
* if (loading) return <p>Loading ...</p>;
|
|
496
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
497
|
+
* }
|
|
498
|
+
* ```
|
|
499
|
+
*
|
|
500
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
501
|
+
* @param options - Options to control how the query is executed.
|
|
502
|
+
* @returns Query result object
|
|
503
|
+
*/
|
|
387
504
|
export declare function useQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
388
505
|
options?: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>
|
|
389
506
|
] : [options: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>]): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming">;
|
|
507
|
+
/**
|
|
508
|
+
* A hook for executing queries in an Apollo application.
|
|
509
|
+
*
|
|
510
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
511
|
+
*
|
|
512
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
513
|
+
*
|
|
514
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
515
|
+
*
|
|
516
|
+
* @example
|
|
517
|
+
*
|
|
518
|
+
* ```jsx
|
|
519
|
+
* import { gql } from "@apollo/client";
|
|
520
|
+
* import { useQuery } from "@apollo/client/react";
|
|
521
|
+
*
|
|
522
|
+
* const GET_GREETING = gql`
|
|
523
|
+
* query GetGreeting($language: String!) {
|
|
524
|
+
* greeting(language: $language) {
|
|
525
|
+
* message
|
|
526
|
+
* }
|
|
527
|
+
* }
|
|
528
|
+
* `;
|
|
529
|
+
*
|
|
530
|
+
* function Hello() {
|
|
531
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
532
|
+
* variables: { language: "english" },
|
|
533
|
+
* });
|
|
534
|
+
* if (loading) return <p>Loading ...</p>;
|
|
535
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
536
|
+
* }
|
|
537
|
+
* ```
|
|
538
|
+
*
|
|
539
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
540
|
+
* @param options - Options to control how the query is executed.
|
|
541
|
+
* @returns Query result object
|
|
542
|
+
*/
|
|
543
|
+
export declare function useQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
544
|
+
options?: SkipToken | useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>
|
|
545
|
+
] : [options: SkipToken | useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>]): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming", Partial<TVariables>>;
|
|
390
546
|
export declare namespace useQuery {
|
|
391
547
|
var ssrDisabledResult: ObservableQuery.Result<any, "complete" | "streaming" | "partial" | "empty">;
|
|
392
548
|
}
|
|
@@ -17,7 +17,8 @@ import * as React from "react";
|
|
|
17
17
|
import { asapScheduler, observeOn } from "rxjs";
|
|
18
18
|
import { NetworkStatus } from "@apollo/client";
|
|
19
19
|
import { maybeDeepFreeze, mergeOptions, } from "@apollo/client/utilities/internal";
|
|
20
|
-
import {
|
|
20
|
+
import { skipToken } from "./constants.js";
|
|
21
|
+
import { useDeepMemo, wrapHook } from "./internal/index.js";
|
|
21
22
|
import { useApolloClient } from "./useApolloClient.js";
|
|
22
23
|
import { useSyncExternalStore } from "./useSyncExternalStore.js";
|
|
23
24
|
const lastWatchOptions = Symbol();
|
|
@@ -25,10 +26,10 @@ export function useQuery(query, ...[options]) {
|
|
|
25
26
|
"use no memo";
|
|
26
27
|
return wrapHook("useQuery",
|
|
27
28
|
// eslint-disable-next-line react-compiler/react-compiler
|
|
28
|
-
useQuery_, useApolloClient(options
|
|
29
|
+
useQuery_, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options);
|
|
29
30
|
}
|
|
30
31
|
function useQuery_(query, t0) {
|
|
31
|
-
const $ = _c(
|
|
32
|
+
const $ = _c(38);
|
|
32
33
|
let t1;
|
|
33
34
|
|
|
34
35
|
if ($[0] !== t0) {
|
|
@@ -40,54 +41,25 @@ function useQuery_(query, t0) {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
const options = t1;
|
|
43
|
-
const client = useApolloClient(options.client);
|
|
44
|
-
let
|
|
45
|
-
let skip;
|
|
44
|
+
const client = useApolloClient(typeof options === "object" ? options.client : undefined);
|
|
45
|
+
let t2;
|
|
46
46
|
|
|
47
47
|
if ($[2] !== options) {
|
|
48
|
-
|
|
49
|
-
skip: t2,
|
|
50
|
-
ssr,
|
|
51
|
-
...t3
|
|
52
|
-
} = options;
|
|
53
|
-
skip = t2;
|
|
54
|
-
opts = t3;
|
|
48
|
+
t2 = typeof options === "object" ? options : {};
|
|
55
49
|
$[2] = options;
|
|
56
|
-
$[3] =
|
|
57
|
-
$[4] = skip;
|
|
58
|
-
} else {
|
|
59
|
-
opts = $[3];
|
|
60
|
-
skip = $[4];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
let watchQueryOptions;
|
|
64
|
-
|
|
65
|
-
if ($[5] !== client.defaultOptions.watchQuery || $[6] !== options.fetchPolicy || $[7] !== options.initialFetchPolicy || $[8] !== opts || $[9] !== query || $[10] !== skip) {
|
|
66
|
-
watchQueryOptions = mergeOptions(client.defaultOptions.watchQuery, {
|
|
67
|
-
...opts,
|
|
68
|
-
query
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
if (skip) {
|
|
72
|
-
watchQueryOptions.initialFetchPolicy = options.initialFetchPolicy || options.fetchPolicy;
|
|
73
|
-
watchQueryOptions.fetchPolicy = "standby";
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
$[5] = client.defaultOptions.watchQuery;
|
|
77
|
-
$[6] = options.fetchPolicy;
|
|
78
|
-
$[7] = options.initialFetchPolicy;
|
|
79
|
-
$[8] = opts;
|
|
80
|
-
$[9] = query;
|
|
81
|
-
$[10] = skip;
|
|
82
|
-
$[11] = watchQueryOptions;
|
|
50
|
+
$[3] = t2;
|
|
83
51
|
} else {
|
|
84
|
-
|
|
52
|
+
t2 = $[3];
|
|
85
53
|
}
|
|
86
54
|
|
|
87
|
-
|
|
55
|
+
const {
|
|
56
|
+
ssr
|
|
57
|
+
} = t2;
|
|
58
|
+
const watchQueryOptions = useOptions(query, options, client.defaultOptions.watchQuery);
|
|
59
|
+
let t3;
|
|
88
60
|
|
|
89
|
-
if ($[
|
|
90
|
-
|
|
61
|
+
if ($[4] !== client || $[5] !== query || $[6] !== watchQueryOptions) {
|
|
62
|
+
t3 = function createState(previous) {
|
|
91
63
|
const observable = client.watchQuery(watchQueryOptions);
|
|
92
64
|
|
|
93
65
|
return {
|
|
@@ -102,31 +74,31 @@ function useQuery_(query, t0) {
|
|
|
102
74
|
}
|
|
103
75
|
};
|
|
104
76
|
};
|
|
105
|
-
$[
|
|
106
|
-
$[
|
|
107
|
-
$[
|
|
108
|
-
$[
|
|
77
|
+
$[4] = client;
|
|
78
|
+
$[5] = query;
|
|
79
|
+
$[6] = watchQueryOptions;
|
|
80
|
+
$[7] = t3;
|
|
109
81
|
} else {
|
|
110
|
-
|
|
82
|
+
t3 = $[7];
|
|
111
83
|
}
|
|
112
84
|
|
|
113
|
-
const createState =
|
|
85
|
+
const createState = t3;
|
|
114
86
|
let [state, setState] = React.useState(createState);
|
|
115
87
|
|
|
116
88
|
if (client !== state.client || query !== state.query) {
|
|
117
|
-
const
|
|
118
|
-
let
|
|
119
|
-
|
|
120
|
-
if ($[
|
|
121
|
-
|
|
122
|
-
$[
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
89
|
+
const t4 = setState;
|
|
90
|
+
let t5;
|
|
91
|
+
|
|
92
|
+
if ($[8] !== createState || $[9] !== state) {
|
|
93
|
+
t5 = createState(state);
|
|
94
|
+
$[8] = createState;
|
|
95
|
+
$[9] = state;
|
|
96
|
+
$[10] = t5;
|
|
125
97
|
} else {
|
|
126
|
-
|
|
98
|
+
t5 = $[10];
|
|
127
99
|
}
|
|
128
100
|
|
|
129
|
-
|
|
101
|
+
t4(state = t5);
|
|
130
102
|
}
|
|
131
103
|
|
|
132
104
|
const {
|
|
@@ -135,112 +107,112 @@ function useQuery_(query, t0) {
|
|
|
135
107
|
} = state;
|
|
136
108
|
useInitialFetchPolicyIfNecessary(watchQueryOptions, observable_0);
|
|
137
109
|
useResubscribeIfNecessary(resultData, observable_0, watchQueryOptions);
|
|
138
|
-
const result = useResult(observable_0, resultData,
|
|
139
|
-
let t3;
|
|
110
|
+
const result = useResult(observable_0, resultData, ssr);
|
|
140
111
|
let t4;
|
|
141
|
-
|
|
142
|
-
if ($[19] !== observable_0) {
|
|
143
|
-
t4 = observable_0.refetch.bind(observable_0);
|
|
144
|
-
$[19] = observable_0;
|
|
145
|
-
$[20] = t4;
|
|
146
|
-
} else {
|
|
147
|
-
t4 = $[20];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
112
|
let t5;
|
|
151
113
|
|
|
152
|
-
if ($[
|
|
153
|
-
t5 = observable_0.
|
|
154
|
-
$[
|
|
155
|
-
$[
|
|
114
|
+
if ($[11] !== observable_0) {
|
|
115
|
+
t5 = observable_0.refetch.bind(observable_0);
|
|
116
|
+
$[11] = observable_0;
|
|
117
|
+
$[12] = t5;
|
|
156
118
|
} else {
|
|
157
|
-
t5 = $[
|
|
119
|
+
t5 = $[12];
|
|
158
120
|
}
|
|
159
121
|
|
|
160
122
|
let t6;
|
|
161
123
|
|
|
162
|
-
if ($[
|
|
163
|
-
t6 = observable_0.
|
|
164
|
-
$[
|
|
165
|
-
$[
|
|
124
|
+
if ($[13] !== observable_0) {
|
|
125
|
+
t6 = observable_0.fetchMore.bind(observable_0);
|
|
126
|
+
$[13] = observable_0;
|
|
127
|
+
$[14] = t6;
|
|
166
128
|
} else {
|
|
167
|
-
t6 = $[
|
|
129
|
+
t6 = $[14];
|
|
168
130
|
}
|
|
169
131
|
|
|
170
132
|
let t7;
|
|
171
133
|
|
|
172
|
-
if ($[
|
|
173
|
-
t7 = observable_0.
|
|
174
|
-
$[
|
|
175
|
-
$[
|
|
134
|
+
if ($[15] !== observable_0) {
|
|
135
|
+
t7 = observable_0.updateQuery.bind(observable_0);
|
|
136
|
+
$[15] = observable_0;
|
|
137
|
+
$[16] = t7;
|
|
176
138
|
} else {
|
|
177
|
-
t7 = $[
|
|
139
|
+
t7 = $[16];
|
|
178
140
|
}
|
|
179
141
|
|
|
180
142
|
let t8;
|
|
181
143
|
|
|
182
|
-
if ($[
|
|
183
|
-
t8 = observable_0.
|
|
184
|
-
$[
|
|
185
|
-
$[
|
|
144
|
+
if ($[17] !== observable_0) {
|
|
145
|
+
t8 = observable_0.startPolling.bind(observable_0);
|
|
146
|
+
$[17] = observable_0;
|
|
147
|
+
$[18] = t8;
|
|
186
148
|
} else {
|
|
187
|
-
t8 = $[
|
|
149
|
+
t8 = $[18];
|
|
188
150
|
}
|
|
189
151
|
|
|
190
152
|
let t9;
|
|
191
153
|
|
|
192
|
-
if ($[
|
|
193
|
-
t9 = observable_0.
|
|
194
|
-
$[
|
|
195
|
-
$[
|
|
154
|
+
if ($[19] !== observable_0) {
|
|
155
|
+
t9 = observable_0.stopPolling.bind(observable_0);
|
|
156
|
+
$[19] = observable_0;
|
|
157
|
+
$[20] = t9;
|
|
196
158
|
} else {
|
|
197
|
-
t9 = $[
|
|
159
|
+
t9 = $[20];
|
|
198
160
|
}
|
|
199
161
|
|
|
200
162
|
let t10;
|
|
201
163
|
|
|
202
|
-
if ($[
|
|
203
|
-
t10 =
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
164
|
+
if ($[21] !== observable_0) {
|
|
165
|
+
t10 = observable_0.subscribeToMore.bind(observable_0);
|
|
166
|
+
$[21] = observable_0;
|
|
167
|
+
$[22] = t10;
|
|
168
|
+
} else {
|
|
169
|
+
t10 = $[22];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
let t11;
|
|
173
|
+
|
|
174
|
+
if ($[23] !== t10 || $[24] !== t5 || $[25] !== t6 || $[26] !== t7 || $[27] !== t8 || $[28] !== t9) {
|
|
175
|
+
t11 = {
|
|
176
|
+
refetch: t5,
|
|
177
|
+
fetchMore: t6,
|
|
178
|
+
updateQuery: t7,
|
|
179
|
+
startPolling: t8,
|
|
180
|
+
stopPolling: t9,
|
|
181
|
+
subscribeToMore: t10
|
|
210
182
|
};
|
|
211
|
-
$[
|
|
212
|
-
$[
|
|
213
|
-
$[
|
|
214
|
-
$[
|
|
215
|
-
$[
|
|
216
|
-
$[
|
|
217
|
-
$[
|
|
183
|
+
$[23] = t10;
|
|
184
|
+
$[24] = t5;
|
|
185
|
+
$[25] = t6;
|
|
186
|
+
$[26] = t7;
|
|
187
|
+
$[27] = t8;
|
|
188
|
+
$[28] = t9;
|
|
189
|
+
$[29] = t11;
|
|
218
190
|
} else {
|
|
219
|
-
|
|
191
|
+
t11 = $[29];
|
|
220
192
|
}
|
|
221
193
|
|
|
222
|
-
|
|
223
|
-
const obsQueryFields =
|
|
194
|
+
t4 = t11;
|
|
195
|
+
const obsQueryFields = t4;
|
|
224
196
|
const previousData = resultData.previousData;
|
|
225
|
-
let
|
|
197
|
+
let t12;
|
|
226
198
|
let rest;
|
|
227
199
|
|
|
228
|
-
if ($[
|
|
200
|
+
if ($[30] !== result) {
|
|
229
201
|
const {
|
|
230
202
|
partial,
|
|
231
|
-
...
|
|
203
|
+
...t13
|
|
232
204
|
} = result;
|
|
233
|
-
rest =
|
|
234
|
-
$[
|
|
235
|
-
$[
|
|
205
|
+
rest = t13;
|
|
206
|
+
$[30] = result;
|
|
207
|
+
$[31] = rest;
|
|
236
208
|
} else {
|
|
237
|
-
rest = $[
|
|
209
|
+
rest = $[31];
|
|
238
210
|
}
|
|
239
211
|
|
|
240
|
-
let
|
|
212
|
+
let t13;
|
|
241
213
|
|
|
242
|
-
if ($[
|
|
243
|
-
|
|
214
|
+
if ($[32] !== client || $[33] !== obsQueryFields || $[34] !== observable_0 || $[35] !== previousData || $[36] !== rest) {
|
|
215
|
+
t13 = {
|
|
244
216
|
...rest,
|
|
245
217
|
client,
|
|
246
218
|
observable: observable_0,
|
|
@@ -248,18 +220,59 @@ function useQuery_(query, t0) {
|
|
|
248
220
|
previousData,
|
|
249
221
|
...obsQueryFields
|
|
250
222
|
};
|
|
251
|
-
$[
|
|
252
|
-
$[
|
|
253
|
-
$[
|
|
254
|
-
$[
|
|
255
|
-
$[
|
|
256
|
-
$[
|
|
223
|
+
$[32] = client;
|
|
224
|
+
$[33] = obsQueryFields;
|
|
225
|
+
$[34] = observable_0;
|
|
226
|
+
$[35] = previousData;
|
|
227
|
+
$[36] = rest;
|
|
228
|
+
$[37] = t13;
|
|
257
229
|
} else {
|
|
258
|
-
|
|
230
|
+
t13 = $[37];
|
|
259
231
|
}
|
|
260
232
|
|
|
261
|
-
|
|
262
|
-
return
|
|
233
|
+
t12 = t13;
|
|
234
|
+
return t12;
|
|
235
|
+
}
|
|
236
|
+
const fromSkipToken = Symbol();
|
|
237
|
+
function useOptions(query, options, defaultOptions) {
|
|
238
|
+
const $ = _c(5);
|
|
239
|
+
let t0;
|
|
240
|
+
let t1;
|
|
241
|
+
|
|
242
|
+
if ($[0] !== defaultOptions || $[1] !== options || $[2] !== query) {
|
|
243
|
+
t0 = () => {
|
|
244
|
+
if (options === skipToken) {
|
|
245
|
+
const opts = mergeOptions(defaultOptions, {
|
|
246
|
+
query,
|
|
247
|
+
fetchPolicy: "standby"
|
|
248
|
+
});
|
|
249
|
+
opts[fromSkipToken] = true;
|
|
250
|
+
return opts;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const watchQueryOptions = mergeOptions(defaultOptions, {
|
|
254
|
+
...options,
|
|
255
|
+
query
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
if (options.skip) {
|
|
259
|
+
watchQueryOptions.initialFetchPolicy = options.initialFetchPolicy || options.fetchPolicy;
|
|
260
|
+
watchQueryOptions.fetchPolicy = "standby";
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return watchQueryOptions;
|
|
264
|
+
};t1 = [query, options, defaultOptions];
|
|
265
|
+
$[0] = defaultOptions;
|
|
266
|
+
$[1] = options;
|
|
267
|
+
$[2] = query;
|
|
268
|
+
$[3] = t0;
|
|
269
|
+
$[4] = t1;
|
|
270
|
+
} else {
|
|
271
|
+
t0 = $[3];
|
|
272
|
+
t1 = $[4];
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return useDeepMemo(t0, t1);
|
|
263
276
|
}
|
|
264
277
|
function useInitialFetchPolicyIfNecessary(watchQueryOptions, observable) {
|
|
265
278
|
"use no memo";
|
|
@@ -316,6 +329,14 @@ observable, watchQueryOptions) {
|
|
|
316
329
|
"use no memo";
|
|
317
330
|
if (observable[lastWatchOptions] &&
|
|
318
331
|
!equal(observable[lastWatchOptions], watchQueryOptions)) {
|
|
332
|
+
// If skipToken was used to generate options, we won't know the correct
|
|
333
|
+
// initialFetchPolicy until the hook is rerendered with real options, so we
|
|
334
|
+
// set it the next time we get real options
|
|
335
|
+
if (observable[lastWatchOptions][fromSkipToken] &&
|
|
336
|
+
!watchQueryOptions.initialFetchPolicy) {
|
|
337
|
+
watchQueryOptions.initialFetchPolicy =
|
|
338
|
+
watchQueryOptions.fetchPolicy;
|
|
339
|
+
}
|
|
319
340
|
// Though it might be tempting to postpone this reobserve call to the
|
|
320
341
|
// useEffect block, we need getCurrentResult to return an appropriate
|
|
321
342
|
// loading:true result synchronously (later within the same call to
|