@apollo/client 4.2.0-alpha.0 → 4.2.0-alpha.2
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 +170 -0
- package/__cjs/core/ApolloClient.cjs +16 -3
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +180 -131
- package/__cjs/core/ObservableQuery.cjs +13 -1
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/QueryManager.cjs +2 -3
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/defaultOptions.cjs +3 -0
- package/__cjs/core/defaultOptions.cjs.map +1 -0
- package/__cjs/core/defaultOptions.d.cts +90 -0
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +2 -1
- package/__cjs/react/hooks/useBackgroundQuery.cjs +3 -3
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +254 -822
- package/__cjs/react/hooks/useLazyQuery.cjs +3 -5
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +93 -146
- package/__cjs/react/hooks/useLoadableQuery.cjs +8 -4
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +105 -233
- package/__cjs/react/hooks/useQuery.cjs +9 -5
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +138 -308
- package/__cjs/react/hooks/useSuspenseQuery.cjs +3 -3
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +147 -436
- package/__cjs/react/internal/cache/getSuspenseCache.cjs.map +1 -1
- package/__cjs/react/internal/cache/getSuspenseCache.d.cts +7 -0
- package/__cjs/utilities/internal/LazyType.cjs +3 -0
- package/__cjs/utilities/internal/LazyType.cjs.map +1 -0
- package/__cjs/utilities/internal/LazyType.d.cts +10 -0
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +3 -0
- package/__cjs/utilities/internal/types/OptionWithFallback.cjs +3 -0
- package/__cjs/utilities/internal/types/OptionWithFallback.cjs.map +1 -0
- package/__cjs/utilities/internal/types/OptionWithFallback.d.cts +5 -0
- package/__cjs/utilities/internal/types/SignatureStyle.cjs +3 -0
- package/__cjs/utilities/internal/types/SignatureStyle.cjs.map +1 -0
- package/__cjs/utilities/internal/types/SignatureStyle.d.cts +24 -0
- package/__cjs/version.cjs +1 -1
- package/core/ApolloClient.d.ts +180 -131
- package/core/ApolloClient.js +16 -3
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.js +13 -1
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.js +3 -4
- package/core/QueryManager.js.map +1 -1
- package/core/defaultOptions.d.ts +90 -0
- package/core/defaultOptions.js +2 -0
- package/core/defaultOptions.js.map +1 -0
- package/core/index.d.ts +2 -1
- package/core/index.js.map +1 -1
- package/package.json +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +254 -822
- package/react/hooks/useBackgroundQuery.js +2 -2
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +93 -146
- package/react/hooks/useLazyQuery.js +2 -4
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +105 -233
- package/react/hooks/useLoadableQuery.js +7 -3
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useQuery.d.ts +138 -308
- package/react/hooks/useQuery.js +7 -3
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +147 -436
- package/react/hooks/useSuspenseQuery.js +2 -2
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +254 -822
- package/react/hooks-compiled/useBackgroundQuery.js +2 -2
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +93 -146
- package/react/hooks-compiled/useLazyQuery.js +2 -4
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +105 -233
- package/react/hooks-compiled/useLoadableQuery.js +2 -2
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +138 -308
- package/react/hooks-compiled/useQuery.js +7 -3
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +147 -436
- package/react/hooks-compiled/useSuspenseQuery.js +2 -2
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/internal/cache/getSuspenseCache.d.ts +7 -0
- package/react/internal/cache/getSuspenseCache.js.map +1 -1
- package/utilities/internal/LazyType.d.ts +10 -0
- package/utilities/internal/LazyType.js +2 -0
- package/utilities/internal/LazyType.js.map +1 -0
- package/utilities/internal/index.d.ts +3 -0
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/types/OptionWithFallback.d.ts +5 -0
- package/utilities/internal/types/OptionWithFallback.js +2 -0
- package/utilities/internal/types/OptionWithFallback.js.map +1 -0
- package/utilities/internal/types/SignatureStyle.d.ts +24 -0
- package/utilities/internal/types/SignatureStyle.js +2 -0
- package/utilities/internal/types/SignatureStyle.js.map +1 -0
- package/version.js +1 -1
|
@@ -2,7 +2,7 @@ import type { DataState, DefaultContext, DocumentNode, ErrorLike, ErrorPolicy, G
|
|
|
2
2
|
import type { ApolloClient } from "@apollo/client";
|
|
3
3
|
import { NetworkStatus } from "@apollo/client";
|
|
4
4
|
import type { MaybeMasked } from "@apollo/client/masking";
|
|
5
|
-
import type { DocumentationTypes as UtilityDocumentationTypes, NoInfer, VariablesOption } from "@apollo/client/utilities/internal";
|
|
5
|
+
import type { DocumentationTypes as UtilityDocumentationTypes, LazyType, NoInfer, OptionWithFallback, SignatureStyle, VariablesOption } from "@apollo/client/utilities/internal";
|
|
6
6
|
import type { SkipToken } from "./constants.cjs";
|
|
7
7
|
export declare namespace useQuery {
|
|
8
8
|
namespace Base {
|
|
@@ -226,6 +226,10 @@ export declare namespace useQuery {
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
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>;
|
|
229
|
+
interface DefaultOptions extends ApolloClient.DefaultOptions.WatchQuery.Calculated {
|
|
230
|
+
skip: false;
|
|
231
|
+
}
|
|
232
|
+
type ResultForOptions<TData, TVariables extends OperationVariables, TOptions extends Record<string, never> | Options<TData, TVariables> | SkipToken> = LazyType<Result<TData, TVariables, "complete" | "streaming" | "empty" | (TOptions extends any ? TOptions extends SkipToken ? never : OptionWithFallback<TOptions, DefaultOptions, "returnPartialData"> extends false ? never : "partial" : never)>>;
|
|
229
233
|
namespace DocumentationTypes {
|
|
230
234
|
namespace useQuery {
|
|
231
235
|
interface Result<TData = unknown, TVariables extends OperationVariables = OperationVariables> extends Base.Result<TData, TVariables>, UtilityDocumentationTypes.DataState<TData> {
|
|
@@ -234,316 +238,142 @@ export declare namespace useQuery {
|
|
|
234
238
|
}
|
|
235
239
|
namespace DocumentationTypes {
|
|
236
240
|
/**
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
241
|
+
* A hook for executing queries in an Apollo application.
|
|
242
|
+
*
|
|
243
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
244
|
+
*
|
|
245
|
+
* 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.
|
|
246
|
+
*
|
|
247
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
*
|
|
251
|
+
* ```jsx
|
|
252
|
+
* import { gql } from "@apollo/client";
|
|
253
|
+
* import { useQuery } from "@apollo/client/react";
|
|
254
|
+
*
|
|
255
|
+
* const GET_GREETING = gql`
|
|
256
|
+
* query GetGreeting($language: String!) {
|
|
257
|
+
* greeting(language: $language) {
|
|
258
|
+
* message
|
|
259
|
+
* }
|
|
260
|
+
* }
|
|
261
|
+
* `;
|
|
262
|
+
*
|
|
263
|
+
* function Hello() {
|
|
264
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
265
|
+
* variables: { language: "english" },
|
|
266
|
+
* });
|
|
267
|
+
* if (loading) return <p>Loading ...</p>;
|
|
268
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
269
|
+
* }
|
|
270
|
+
* ```
|
|
271
|
+
*
|
|
272
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
273
|
+
* @param options - Options to control how the query is executed.
|
|
274
|
+
* @returns Query result object
|
|
275
|
+
*/
|
|
276
|
+
interface useQuery {
|
|
277
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useQuery.Options<TData, TVariables>): useQuery.Result<TData, TVariables>;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* @deprecated Avoid manually specifying generics on `useQuery`.
|
|
281
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
282
|
+
*/
|
|
283
|
+
interface useQuery_Deprecated {
|
|
284
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useQuery.Options<TData, TVariables>): useQuery.Result<TData, TVariables>;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
namespace Signatures {
|
|
288
|
+
/**
|
|
258
289
|
*
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
290
|
+
*/
|
|
291
|
+
interface Classic {
|
|
292
|
+
/**
|
|
293
|
+
*
|
|
294
|
+
*/
|
|
295
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
296
|
+
returnPartialData: true;
|
|
297
|
+
}): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming" | "partial">;
|
|
298
|
+
/**
|
|
299
|
+
*
|
|
300
|
+
*/
|
|
301
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken): useQuery.Result<TData, TVariables, "empty", Record<string, never>>;
|
|
302
|
+
/**
|
|
303
|
+
*
|
|
304
|
+
*/
|
|
305
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
306
|
+
returnPartialData: true;
|
|
307
|
+
})): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming" | "partial", Partial<TVariables>>;
|
|
308
|
+
/**
|
|
309
|
+
*
|
|
310
|
+
*/
|
|
311
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
312
|
+
returnPartialData: boolean;
|
|
313
|
+
}): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming" | "partial">;
|
|
314
|
+
/**
|
|
315
|
+
*
|
|
316
|
+
*/
|
|
317
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
318
|
+
returnPartialData: boolean;
|
|
319
|
+
})): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming" | "partial", Partial<TVariables>>;
|
|
320
|
+
/**
|
|
321
|
+
*
|
|
322
|
+
*/
|
|
323
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
324
|
+
options?: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>
|
|
325
|
+
] : [options: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>]): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming">;
|
|
326
|
+
/**
|
|
327
|
+
*
|
|
328
|
+
*/
|
|
329
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
330
|
+
options?: SkipToken | useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>
|
|
331
|
+
] : [
|
|
332
|
+
options: SkipToken | useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>
|
|
333
|
+
]): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming", Partial<TVariables>>;
|
|
334
|
+
ssrDisabledResult: ObservableQuery.Result<any>;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
267
337
|
*
|
|
268
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
269
|
-
* @param options - Options to control how the query is executed.
|
|
270
|
-
* @returns Query result object
|
|
271
338
|
*/
|
|
272
|
-
|
|
339
|
+
interface Modern {
|
|
340
|
+
/**
|
|
341
|
+
*
|
|
342
|
+
*/
|
|
343
|
+
<TData, TVariables extends OperationVariables, Options extends never>(query: {} extends TVariables ? DocumentNode | TypedDocumentNode<TData, TVariables> : never): useQuery.ResultForOptions<TData, TVariables, Record<string, never>>;
|
|
344
|
+
/**
|
|
345
|
+
*
|
|
346
|
+
*/
|
|
347
|
+
<TData, TVariables extends OperationVariables, TOptions extends SkipToken>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken): useQuery.Result<TData, TVariables, "empty", Record<string, never>>;
|
|
348
|
+
/**
|
|
349
|
+
*
|
|
350
|
+
*/
|
|
351
|
+
<TData, TVariables extends OperationVariables, TOptions extends useQuery.Options<TData, NoInfer<TVariables>> & VariablesOption<TVariables & {
|
|
352
|
+
[K in Exclude<keyof TOptions["variables"], keyof TVariables>]?: never;
|
|
353
|
+
}>>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: [
|
|
354
|
+
TVariables
|
|
355
|
+
] extends [never] ? [options: never] : {} extends TVariables ? [options?: TOptions] : [
|
|
356
|
+
options: TOptions
|
|
357
|
+
]): useQuery.ResultForOptions<TData, TVariables, TOptions>;
|
|
358
|
+
/**
|
|
359
|
+
*
|
|
360
|
+
*/
|
|
361
|
+
<TData, TVariables extends OperationVariables, TOptions extends useQuery.Options<TData, NoInfer<TVariables>> & VariablesOption<TVariables & {
|
|
362
|
+
[K in Exclude<keyof TOptions["variables"], keyof TVariables>]?: never;
|
|
363
|
+
}>>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: [
|
|
364
|
+
TVariables
|
|
365
|
+
] extends [never] ? [options: never] : {} extends TVariables ? [options?: TOptions | SkipToken] : [
|
|
366
|
+
options: TOptions | SkipToken
|
|
367
|
+
]): useQuery.ResultForOptions<TData, TVariables, TOptions | SkipToken>;
|
|
368
|
+
ssrDisabledResult: ObservableQuery.Result<any>;
|
|
369
|
+
}
|
|
370
|
+
type Evaluated = SignatureStyle extends "classic" ? Classic : Modern;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
*
|
|
374
|
+
*/
|
|
375
|
+
interface Signature extends Signatures.Evaluated {
|
|
273
376
|
}
|
|
274
377
|
}
|
|
275
|
-
|
|
276
|
-
* A hook for executing queries in an Apollo application.
|
|
277
|
-
*
|
|
278
|
-
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
279
|
-
*
|
|
280
|
-
* 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.
|
|
281
|
-
*
|
|
282
|
-
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
*
|
|
286
|
-
* ```jsx
|
|
287
|
-
* import { gql } from "@apollo/client";
|
|
288
|
-
* import { useQuery } from "@apollo/client/react";
|
|
289
|
-
*
|
|
290
|
-
* const GET_GREETING = gql`
|
|
291
|
-
* query GetGreeting($language: String!) {
|
|
292
|
-
* greeting(language: $language) {
|
|
293
|
-
* message
|
|
294
|
-
* }
|
|
295
|
-
* }
|
|
296
|
-
* `;
|
|
297
|
-
*
|
|
298
|
-
* function Hello() {
|
|
299
|
-
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
300
|
-
* variables: { language: "english" },
|
|
301
|
-
* });
|
|
302
|
-
* if (loading) return <p>Loading ...</p>;
|
|
303
|
-
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
304
|
-
* }
|
|
305
|
-
* ```
|
|
306
|
-
*
|
|
307
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
308
|
-
* @param options - Options to control how the query is executed.
|
|
309
|
-
* @returns Query result object
|
|
310
|
-
*/
|
|
311
|
-
export declare function useQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
312
|
-
returnPartialData: true;
|
|
313
|
-
}): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming" | "partial">;
|
|
314
|
-
/**
|
|
315
|
-
* A hook for executing queries in an Apollo application.
|
|
316
|
-
*
|
|
317
|
-
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
318
|
-
*
|
|
319
|
-
* 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.
|
|
320
|
-
*
|
|
321
|
-
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
322
|
-
*
|
|
323
|
-
* @example
|
|
324
|
-
*
|
|
325
|
-
* ```jsx
|
|
326
|
-
* import { gql } from "@apollo/client";
|
|
327
|
-
* import { useQuery } from "@apollo/client/react";
|
|
328
|
-
*
|
|
329
|
-
* const GET_GREETING = gql`
|
|
330
|
-
* query GetGreeting($language: String!) {
|
|
331
|
-
* greeting(language: $language) {
|
|
332
|
-
* message
|
|
333
|
-
* }
|
|
334
|
-
* }
|
|
335
|
-
* `;
|
|
336
|
-
*
|
|
337
|
-
* function Hello() {
|
|
338
|
-
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
339
|
-
* variables: { language: "english" },
|
|
340
|
-
* });
|
|
341
|
-
* if (loading) return <p>Loading ...</p>;
|
|
342
|
-
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
343
|
-
* }
|
|
344
|
-
* ```
|
|
345
|
-
*
|
|
346
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
347
|
-
* @param options - Options to control how the query is executed.
|
|
348
|
-
* @returns Query result object
|
|
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
|
-
*/
|
|
426
|
-
export declare function useQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
427
|
-
returnPartialData: boolean;
|
|
428
|
-
}): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming" | "partial">;
|
|
429
|
-
/**
|
|
430
|
-
* A hook for executing queries in an Apollo application.
|
|
431
|
-
*
|
|
432
|
-
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
433
|
-
*
|
|
434
|
-
* 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.
|
|
435
|
-
*
|
|
436
|
-
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
437
|
-
*
|
|
438
|
-
* @example
|
|
439
|
-
*
|
|
440
|
-
* ```jsx
|
|
441
|
-
* import { gql } from "@apollo/client";
|
|
442
|
-
* import { useQuery } from "@apollo/client/react";
|
|
443
|
-
*
|
|
444
|
-
* const GET_GREETING = gql`
|
|
445
|
-
* query GetGreeting($language: String!) {
|
|
446
|
-
* greeting(language: $language) {
|
|
447
|
-
* message
|
|
448
|
-
* }
|
|
449
|
-
* }
|
|
450
|
-
* `;
|
|
451
|
-
*
|
|
452
|
-
* function Hello() {
|
|
453
|
-
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
454
|
-
* variables: { language: "english" },
|
|
455
|
-
* });
|
|
456
|
-
* if (loading) return <p>Loading ...</p>;
|
|
457
|
-
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
458
|
-
* }
|
|
459
|
-
* ```
|
|
460
|
-
*
|
|
461
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
462
|
-
* @param options - Options to control how the query is executed.
|
|
463
|
-
* @returns Query result object
|
|
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
|
-
*/
|
|
504
|
-
export declare function useQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
505
|
-
options?: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>
|
|
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>>;
|
|
546
|
-
export declare namespace useQuery {
|
|
547
|
-
var ssrDisabledResult: ObservableQuery.Result<any, "complete" | "empty" | "streaming" | "partial">;
|
|
548
|
-
}
|
|
378
|
+
export declare const useQuery: useQuery.Signature;
|
|
549
379
|
//# sourceMappingURL=useQuery.d.cts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useSuspenseQuery =
|
|
3
|
+
exports.useSuspenseQuery = void 0;
|
|
4
4
|
exports.useWatchQueryOptions = useWatchQueryOptions;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const React = tslib_1.__importStar(require("react"));
|
|
@@ -12,10 +12,10 @@ const constants_js_1 = require("./constants.cjs");
|
|
|
12
12
|
const index_js_1 = require("./internal/index.cjs");
|
|
13
13
|
const validateSuspenseHookOptions_js_1 = require("./internal/validateSuspenseHookOptions.cjs");
|
|
14
14
|
const useApolloClient_js_1 = require("./useApolloClient.cjs");
|
|
15
|
-
function useSuspenseQuery(query, options) {
|
|
15
|
+
exports.useSuspenseQuery = function useSuspenseQuery(query, options) {
|
|
16
16
|
"use no memo";
|
|
17
17
|
return (0, index_js_1.wrapHook)("useSuspenseQuery", useSuspenseQuery_, (0, useApolloClient_js_1.useApolloClient)(typeof options === "object" ? options.client : undefined))(query, options ?? {});
|
|
18
|
-
}
|
|
18
|
+
};
|
|
19
19
|
function useSuspenseQuery_(query, options) {
|
|
20
20
|
const client = (0, useApolloClient_js_1.useApolloClient)(options.client);
|
|
21
21
|
const suspenseCache = (0, internal_1.getSuspenseCache)(client);
|