@apollo/client 4.3.0-alpha.4 → 4.3.0-alpha.6
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 +116 -0
- package/README.md +3 -7
- package/__cjs/cache/core/cache.cjs +1 -1
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +5 -1
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/inMemoryCache.cjs +0 -4
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +3 -4
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +28 -6
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.cjs +71 -54
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.d.cts +1 -1
- package/__cjs/cache/inmemory/types.d.cts +1 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/core/ApolloClient.cjs +21 -22
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +44 -10
- package/__cjs/core/ObservableQuery.cjs +56 -14
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +13 -2
- package/__cjs/core/QueryInfo.cjs +175 -161
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +15 -5
- package/__cjs/core/QueryManager.cjs +63 -38
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/RefetchEventManager.cjs +3 -3
- package/__cjs/core/dataStateErrorCache.cjs +12 -0
- package/__cjs/core/dataStateErrorCache.cjs.map +1 -0
- package/__cjs/core/dataStateErrorCache.d.cts +3 -0
- package/__cjs/core/types.d.cts +2 -0
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs +34 -11
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +1 -1
- package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +26 -3
- package/__cjs/incremental/types.d.cts +41 -3
- package/__cjs/invariantErrorCodes.cjs +56 -32
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +100 -47
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +26 -20
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +23 -15
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +10 -7
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +74 -32
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +83 -34
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/internal/types.d.cts +14 -3
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.d.cts +20 -5
- package/__cjs/testing/core/mocking/mockLink.cjs +21 -1
- package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockLink.d.cts +1 -2
- package/__cjs/utilities/internal/addDeferFragmentLabels.cjs +33 -0
- package/__cjs/utilities/internal/addDeferFragmentLabels.cjs.map +1 -0
- package/__cjs/utilities/internal/addDeferFragmentLabels.d.cts +3 -0
- package/__cjs/utilities/internal/getDirectiveArgValue.cjs +19 -0
- package/__cjs/utilities/internal/getDirectiveArgValue.cjs.map +1 -0
- package/__cjs/utilities/internal/getDirectiveArgValue.d.cts +9 -0
- package/__cjs/utilities/internal/index.cjs +8 -2
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +3 -0
- package/__cjs/utilities/internal/toDiffWithDataState.cjs +20 -0
- package/__cjs/utilities/internal/toDiffWithDataState.cjs.map +1 -0
- package/__cjs/utilities/internal/toDiffWithDataState.d.cts +8 -0
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.d.ts +5 -1
- package/cache/core/cache.js +1 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/inMemoryCache.d.ts +3 -4
- package/cache/inmemory/inMemoryCache.js +1 -5
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +28 -6
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +1 -1
- package/cache/inmemory/readFromStore.js +72 -55
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +1 -2
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.js +4 -4
- package/core/ApolloClient.d.ts +44 -10
- package/core/ApolloClient.js +21 -22
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +13 -2
- package/core/ObservableQuery.js +57 -15
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +15 -5
- package/core/QueryInfo.js +171 -161
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +63 -38
- package/core/QueryManager.js.map +1 -1
- package/core/RefetchEventManager.js +3 -3
- package/core/dataStateErrorCache.d.ts +3 -0
- package/core/dataStateErrorCache.js +9 -0
- package/core/dataStateErrorCache.js.map +1 -0
- package/core/types.d.ts +2 -0
- package/core/types.js.map +1 -1
- package/incremental/handlers/graphql17Alpha9.d.ts +26 -3
- package/incremental/handlers/graphql17Alpha9.js +35 -12
- package/incremental/handlers/graphql17Alpha9.js.map +1 -1
- package/incremental/types.d.ts +41 -3
- package/incremental/types.js.map +1 -1
- package/invariantErrorCodes.js +56 -32
- package/package.json +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +100 -47
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +26 -20
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +23 -15
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +10 -7
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +74 -32
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +83 -34
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +100 -47
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +26 -20
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +23 -15
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useMutation.d.ts +10 -7
- package/react/hooks-compiled/useMutation.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +74 -32
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +83 -34
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/types.d.ts +15 -4
- package/react/internal/types.js.map +1 -1
- package/react/query-preloader/createQueryPreloader.d.ts +20 -5
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +1 -2
- package/testing/core/mocking/mockLink.js +21 -1
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/utilities/internal/addDeferFragmentLabels.d.ts +3 -0
- package/utilities/internal/addDeferFragmentLabels.js +30 -0
- package/utilities/internal/addDeferFragmentLabels.js.map +1 -0
- package/utilities/internal/getDirectiveArgValue.d.ts +9 -0
- package/utilities/internal/getDirectiveArgValue.js +16 -0
- package/utilities/internal/getDirectiveArgValue.js.map +1 -0
- package/utilities/internal/index.d.ts +3 -0
- package/utilities/internal/index.js +3 -0
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/toDiffWithDataState.d.ts +8 -0
- package/utilities/internal/toDiffWithDataState.js +17 -0
- package/utilities/internal/toDiffWithDataState.js.map +1 -0
- package/version.js +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DocumentNode, FieldNode } from "graphql";
|
|
2
2
|
import type { OperationVariables } from "@apollo/client";
|
|
3
3
|
import type { Reference, StoreObject, StoreValue } from "@apollo/client/utilities";
|
|
4
|
-
import type { DeferInfoTrie, ExtensionsWithStreamInfo,
|
|
4
|
+
import type { DeferInfoTrie, ExtensionsWithStreamInfo, RemoveIndexSignature, StreamInfoTrie } from "@apollo/client/utilities/internal";
|
|
5
5
|
import type { ApolloCache, Transaction } from "../core/cache.js";
|
|
6
6
|
import type { AllFieldsModifier, CanReadFunction, Modifiers, ToReferenceFunction } from "../core/types/common.js";
|
|
7
7
|
import type { FieldValueGetter } from "./entityStore.js";
|
|
@@ -90,7 +90,6 @@ export interface DiffIncrementalInfo {
|
|
|
90
90
|
}
|
|
91
91
|
export type DiffQueryAgainstStoreOptions = ReadQueryOptions & {
|
|
92
92
|
returnPartialData?: boolean;
|
|
93
|
-
[handleIncrementalSymbol]?: true | DiffIncrementalInfo;
|
|
94
93
|
};
|
|
95
94
|
export type ApolloReducerConfig = {
|
|
96
95
|
dataIdFromObject?: KeyFieldsFunction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/cache/inmemory/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DocumentNode, FieldNode } from \"graphql\";\n\nimport type { OperationVariables } from \"@apollo/client\";\nimport type {\n Reference,\n StoreObject,\n StoreValue,\n} from \"@apollo/client/utilities\";\nimport type {\n DeferInfoTrie,\n ExtensionsWithStreamInfo,\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/cache/inmemory/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DocumentNode, FieldNode } from \"graphql\";\n\nimport type { OperationVariables } from \"@apollo/client\";\nimport type {\n Reference,\n StoreObject,\n StoreValue,\n} from \"@apollo/client/utilities\";\nimport type {\n DeferInfoTrie,\n ExtensionsWithStreamInfo,\n RemoveIndexSignature,\n StreamInfoTrie,\n} from \"@apollo/client/utilities/internal\";\n\nimport type { ApolloCache, Transaction } from \"../core/cache.js\";\nimport type {\n AllFieldsModifier,\n CanReadFunction,\n Modifiers,\n ToReferenceFunction,\n} from \"../core/types/common.js\";\n\nimport type { FieldValueGetter } from \"./entityStore.js\";\nimport type { FragmentRegistryAPI } from \"./fragmentRegistry.js\";\nimport type { InMemoryCache } from \"./inMemoryCache.js\";\nimport type {\n FieldMergeFunction,\n KeyFieldsFunction,\n PossibleTypesMap,\n StorageType,\n TypePolicies,\n} from \"./policies.js\";\n\nexport type { Reference, StoreObject, StoreValue };\n\nexport interface IdGetterObj extends Object {\n __typename?: string;\n id?: string;\n _id?: string;\n}\n\nexport declare type IdGetter = (value: IdGetterObj) => string | undefined;\n\n/**\n * This is an interface used to access, set and remove\n * StoreObjects from the cache\n */\nexport interface NormalizedCache {\n has(dataId: string): boolean;\n get(dataId: string, fieldName: string): StoreValue;\n\n // The store.merge method allows either argument to be a string ID, but\n // the other argument has to be a StoreObject. Either way, newer fields\n // always take precedence over older fields.\n merge(olderId: string, newerObject: StoreObject): void;\n merge(olderObject: StoreObject, newerId: string): void;\n\n modify<Entity extends Record<string, any>>(\n dataId: string,\n fields: Modifiers<Entity> | AllFieldsModifier<Entity>,\n exact: boolean\n ): boolean;\n delete(dataId: string, fieldName?: string): boolean;\n clear(): void;\n\n // non-Map elements:\n /**\n * returns an Object with key-value pairs matching the contents of the store\n */\n toObject(): NormalizedCacheObject;\n /**\n * replace the state of the store\n */\n replace(newData: NormalizedCacheObject): void;\n\n /**\n * Retain (or release) a given root ID to protect (or expose) it and its\n * transitive child entities from (or to) garbage collection. The current\n * retainment count is returned by both methods. Note that releasing a root\n * ID does not cause that entity to be garbage collected, but merely removes\n * it from the set of root IDs that will be considered during the next\n * mark-and-sweep collection.\n */\n retain(rootId: string): number;\n release(rootId: string): number;\n\n getFieldValue: FieldValueGetter;\n toReference: ToReferenceFunction;\n canRead: CanReadFunction;\n\n getStorage(\n idOrObj: string | StoreObject,\n ...storeFieldNames: (string | number)[]\n ): StorageType;\n}\n\n/**\n * This is a normalized representation of the Apollo query result cache. It consists of\n * a flattened representation of query result trees.\n */\nexport interface NormalizedCacheObject {\n __META?: {\n // Well-known singleton IDs like ROOT_QUERY and ROOT_MUTATION are\n // always considered to be root IDs during cache.gc garbage\n // collection, but other IDs can become roots if they are written\n // directly with cache.writeFragment or retained explicitly with\n // cache.retain. When such IDs exist, we include them in the __META\n // section so that they can survive cache.{extract,restore}.\n extraRootIds: string[];\n };\n [dataId: string]: StoreObject | undefined;\n}\n\nexport type OptimisticStoreItem = {\n id: string;\n data: NormalizedCacheObject;\n transaction: Transaction;\n};\n\nexport type ReadQueryOptions = {\n /**\n * The Apollo Client store object.\n */\n store: NormalizedCache;\n /**\n * A parsed GraphQL query document.\n */\n query: DocumentNode;\n variables?: Object;\n previousResult?: any;\n rootId?: string;\n config?: ApolloReducerConfig;\n};\n\n/** @internal */\nexport interface DiffIncrementalInfo {\n streamInfo?: StreamInfoTrie;\n deferInfo?: DeferInfoTrie;\n}\n\nexport type DiffQueryAgainstStoreOptions = ReadQueryOptions & {\n returnPartialData?: boolean;\n};\n\nexport type ApolloReducerConfig = {\n dataIdFromObject?: KeyFieldsFunction;\n};\n\nexport interface InputObjectConfig {\n fields: Record<string, string>;\n}\n\nexport interface InputObjectsOption {\n [inputObjectName: string]: InputObjectConfig;\n}\n\nexport type InMemoryCacheConfig = ApolloReducerConfig & {\n resultCaching?: boolean;\n possibleTypes?: PossibleTypesMap;\n typePolicies?: TypePolicies;\n fragments?: FragmentRegistryAPI;\n inputObjects?: InputObjectsOption;\n} & ({} extends InMemoryCache.ScalarsOption ?\n InMemoryCache.ScalarsOption extends Record<string, never> ?\n {\n scalars?: Record<\n string,\n `Scalar types must be declared in ApolloCache.Scalars before usage. See https://www.apollographql.com/docs/react/data/typescript#declaring-scalar-types.`\n >;\n }\n : { scalars?: InMemoryCache.ScalarsOption }\n : { scalars: InMemoryCache.ScalarsOption });\n\nexport interface MergeInfo {\n field: FieldNode;\n typename: string | undefined;\n merge: FieldMergeFunction;\n path: Array<string | number>;\n}\n\nexport interface MergeTree {\n info?: MergeInfo;\n map: Map<string | number, MergeTree>;\n}\n\nexport interface ReadMergeModifyContext {\n store: NormalizedCache;\n variables?: OperationVariables;\n // A JSON.stringify-serialized version of context.variables.\n varString?: string;\n extensions?: ExtensionsWithStreamInfo;\n}\n\nexport type KnownScalars = RemoveIndexSignature<ApolloCache.Scalars>;\nexport type ScalarNames =\n | keyof KnownScalars\n | (string extends keyof ApolloCache.Scalars ? string & {} : never);\n"]}
|
|
@@ -68,7 +68,7 @@ export class StoreWriter {
|
|
|
68
68
|
path: [],
|
|
69
69
|
});
|
|
70
70
|
if (!isReference(ref)) {
|
|
71
|
-
throw newInvariantError(
|
|
71
|
+
throw newInvariantError(117, result);
|
|
72
72
|
}
|
|
73
73
|
// So far, the store has not been modified, so now it's time to process
|
|
74
74
|
// context.incomingById and merge those incoming fields into context.store.
|
|
@@ -230,7 +230,7 @@ export class StoreWriter {
|
|
|
230
230
|
// provide a default value, so its absence from the written data should
|
|
231
231
|
// not be cause for alarm.
|
|
232
232
|
!policies.getReadFunction(typename, field.name.value)) {
|
|
233
|
-
invariant.error(
|
|
233
|
+
invariant.error(118, resultKeyNameFromField(field), result);
|
|
234
234
|
}
|
|
235
235
|
});
|
|
236
236
|
// Identify the result object, even if dataId was already provided,
|
|
@@ -378,7 +378,7 @@ export class StoreWriter {
|
|
|
378
378
|
else {
|
|
379
379
|
const fragment = getFragmentFromSelection(selection, context.lookupFragment);
|
|
380
380
|
if (!fragment && selection.kind === Kind.FRAGMENT_SPREAD) {
|
|
381
|
-
throw newInvariantError(
|
|
381
|
+
throw newInvariantError(119, selection.name.value);
|
|
382
382
|
}
|
|
383
383
|
if (fragment &&
|
|
384
384
|
policies.fragmentMatches(fragment, typename, result, context.variables)) {
|
|
@@ -550,7 +550,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
|
550
550
|
}
|
|
551
551
|
});
|
|
552
552
|
}
|
|
553
|
-
__DEV__ && invariant.warn(
|
|
553
|
+
__DEV__ && invariant.warn(120, fieldName, parentType, childTypenames.length ?
|
|
554
554
|
"either ensure all objects of type " +
|
|
555
555
|
childTypenames.join(" and ") +
|
|
556
556
|
" have an ID or a custom merge function, or "
|
package/core/ApolloClient.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { ClientAwarenessLink } from "@apollo/client/link/client-awareness";
|
|
|
8
8
|
import type { LocalState } from "@apollo/client/local-state";
|
|
9
9
|
import type { MaybeMasked, Unmasked } from "@apollo/client/masking";
|
|
10
10
|
import { DocumentTransform } from "@apollo/client/utilities";
|
|
11
|
-
import type { LazyType, OptionWithFallback, SignatureStyle, VariablesOption, variablesUnknownSymbol } from "@apollo/client/utilities/internal";
|
|
11
|
+
import type { LazyType, OptionWithFallback, Prettify, SignatureStyle, VariablesOption, variablesUnknownSymbol } from "@apollo/client/utilities/internal";
|
|
12
12
|
import { getApolloClientMemoryInternals } from "@apollo/client/utilities/internal";
|
|
13
13
|
import type { DeclareDefaultOptions, DefaultOptions } from "./defaultOptions.js";
|
|
14
14
|
import type { ObservableQuery } from "./ObservableQuery.js";
|
|
@@ -232,7 +232,20 @@ export declare namespace ApolloClient {
|
|
|
232
232
|
export namespace mutate {
|
|
233
233
|
interface DefaultOptions extends ApolloClient.DefaultOptions.Mutate.Calculated {
|
|
234
234
|
}
|
|
235
|
-
type
|
|
235
|
+
type OptionsFor<TData, TVariables extends OperationVariables, TCache extends Cache.Implementation, TOptions extends {
|
|
236
|
+
variables?: unknown;
|
|
237
|
+
}> = MutateOptions<NoInfer<TData>, NoInfer<TVariables>, TCache> & {
|
|
238
|
+
variables?: Prettify<TVariables & {
|
|
239
|
+
[K in keyof TOptions["variables"]]: K extends keyof TVariables ? TVariables[K] : never;
|
|
240
|
+
}>;
|
|
241
|
+
} & (Exclude<keyof TOptions, keyof MutateOptions<any, any, any>> extends (infer InvalidOptionNames extends string) ? [
|
|
242
|
+
InvalidOptionNames
|
|
243
|
+
] extends [never] ? unknown : {
|
|
244
|
+
[K in InvalidOptionNames]: never;
|
|
245
|
+
} : never);
|
|
246
|
+
type ResultForOptions<TData, TErrorPolicy extends ErrorPolicy | undefined = undefined> = LazyType<MutateResult<MaybeMasked<TData>, OptionWithFallback<{
|
|
247
|
+
errorPolicy: TErrorPolicy;
|
|
248
|
+
}, DefaultOptions, "errorPolicy"> & ErrorPolicy>>;
|
|
236
249
|
namespace Signatures {
|
|
237
250
|
interface Classic {
|
|
238
251
|
/**
|
|
@@ -271,11 +284,21 @@ export declare namespace ApolloClient {
|
|
|
271
284
|
*
|
|
272
285
|
* It takes options as an object with the following keys and values:
|
|
273
286
|
*/
|
|
274
|
-
<TData, TVariables extends OperationVariables, TOptions extends ApolloClient.MutateOptions<NoInfer<TData>,
|
|
275
|
-
|
|
276
|
-
}
|
|
287
|
+
<TData, TVariables extends OperationVariables, TOptions extends Omit<ApolloClient.MutateOptions<NoInfer<TData>, any, Cache.Implementation>, "variables"> & {
|
|
288
|
+
variables?: unknown;
|
|
289
|
+
}, TErrorPolicy extends ErrorPolicy | undefined = undefined>(options: TOptions & ApolloClient.mutate.OptionsFor<TData, TVariables, Cache.Implementation, TOptions> & {
|
|
277
290
|
mutation: TypedDocumentNode<TData, TVariables>;
|
|
278
|
-
|
|
291
|
+
/**
|
|
292
|
+
* Specifies how the mutation handles a response that returns both GraphQL errors and partial results.
|
|
293
|
+
*
|
|
294
|
+
* For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).
|
|
295
|
+
*
|
|
296
|
+
* The default value is `none`, meaning that the mutation result includes error details but _not_ partial results.
|
|
297
|
+
*
|
|
298
|
+
* @docGroup 1. Operation options
|
|
299
|
+
*/
|
|
300
|
+
errorPolicy?: TErrorPolicy;
|
|
301
|
+
}): Promise<ApolloClient.mutate.ResultForOptions<TData, TErrorPolicy>>;
|
|
279
302
|
}
|
|
280
303
|
type Evaluated = SignatureStyle extends "classic" ? Classic : Modern;
|
|
281
304
|
}
|
|
@@ -473,7 +496,18 @@ export declare namespace ApolloClient {
|
|
|
473
496
|
export namespace query {
|
|
474
497
|
interface DefaultOptions extends ApolloClient.DefaultOptions.Query.Calculated {
|
|
475
498
|
}
|
|
476
|
-
type
|
|
499
|
+
type OptionsFor<TData, TVariables extends OperationVariables, TOptions extends {
|
|
500
|
+
variables?: unknown;
|
|
501
|
+
}> = QueryOptions<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
502
|
+
variables?: Prettify<TVariables & {
|
|
503
|
+
[K in keyof TOptions["variables"]]: K extends keyof TVariables ? TVariables[K] : never;
|
|
504
|
+
}>;
|
|
505
|
+
} & (Exclude<keyof TOptions, keyof QueryOptions<any, any>> extends (infer InvalidOptionNames extends string) ? [
|
|
506
|
+
InvalidOptionNames
|
|
507
|
+
] extends [never] ? unknown : {
|
|
508
|
+
[K in InvalidOptionNames]: never;
|
|
509
|
+
} : never);
|
|
510
|
+
type ResultForOptions<TData, TVariables extends OperationVariables, TOptions extends Record<string, unknown> | Omit<QueryOptions<any, any>, "variables">> = LazyType<QueryResult<MaybeMasked<TData>, OptionWithFallback<TOptions, DefaultOptions, "errorPolicy"> & ErrorPolicy>>;
|
|
477
511
|
namespace Signatures {
|
|
478
512
|
interface Classic {
|
|
479
513
|
/**
|
|
@@ -515,9 +549,9 @@ export declare namespace ApolloClient {
|
|
|
515
549
|
* describe how this query should be treated e.g. whether it should hit the
|
|
516
550
|
* server at all or just resolve from the cache, etc.
|
|
517
551
|
*/
|
|
518
|
-
<TData, TVariables extends OperationVariables, TOptions extends ApolloClient.QueryOptions<NoInfer<TData>,
|
|
519
|
-
|
|
520
|
-
}
|
|
552
|
+
<TData, TVariables extends OperationVariables, TOptions extends Omit<ApolloClient.QueryOptions<NoInfer<TData>, any>, "variables"> & {
|
|
553
|
+
variables?: unknown;
|
|
554
|
+
}>(options: TOptions & ApolloClient.query.OptionsFor<TData, TVariables, TOptions> & {
|
|
521
555
|
query: TypedDocumentNode<TData, TVariables>;
|
|
522
556
|
}): Promise<ApolloClient.query.ResultForOptions<TData, TVariables, TOptions>>;
|
|
523
557
|
}
|
package/core/ApolloClient.js
CHANGED
|
@@ -141,29 +141,28 @@ export class ApolloClient {
|
|
|
141
141
|
*/
|
|
142
142
|
if (!hasSuggestedDevtools && __DEV__) {
|
|
143
143
|
hasSuggestedDevtools = true;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
const win = window;
|
|
145
|
+
const ua = win.navigator.userAgent;
|
|
146
|
+
let url;
|
|
147
|
+
if (typeof ua === "string") {
|
|
148
|
+
if (ua.indexOf("Chrome/") > -1) {
|
|
149
|
+
url =
|
|
150
|
+
"https://chrome.google.com/webstore/detail/" +
|
|
151
|
+
"apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm";
|
|
152
|
+
}
|
|
153
|
+
else if (ua.indexOf("Firefox/") > -1) {
|
|
154
|
+
url =
|
|
155
|
+
"https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/";
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (win.document &&
|
|
159
|
+
win.top === win.self &&
|
|
160
|
+
/^(https?|file):$/.test(win.location.protocol) &&
|
|
161
|
+
url) {
|
|
147
162
|
setTimeout(() => {
|
|
148
|
-
if (!
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
let url;
|
|
152
|
-
if (typeof ua === "string") {
|
|
153
|
-
if (ua.indexOf("Chrome/") > -1) {
|
|
154
|
-
url =
|
|
155
|
-
"https://chrome.google.com/webstore/detail/" +
|
|
156
|
-
"apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm";
|
|
157
|
-
}
|
|
158
|
-
else if (ua.indexOf("Firefox/") > -1) {
|
|
159
|
-
url =
|
|
160
|
-
"https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/";
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
if (url) {
|
|
164
|
-
__DEV__ && invariant.log("Download the Apollo DevTools for a better development " +
|
|
165
|
-
"experience: %s", url);
|
|
166
|
-
}
|
|
163
|
+
if (!win.__APOLLO_DEVTOOLS_GLOBAL_HOOK__) {
|
|
164
|
+
__DEV__ && invariant.log("Download the Apollo DevTools for a better development " +
|
|
165
|
+
"experience: %s", url);
|
|
167
166
|
}
|
|
168
167
|
}, 10000);
|
|
169
168
|
}
|