@apollo/client 4.0.0-alpha.4 → 4.0.0-alpha.5
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/.changeset/eleven-kangaroos-jump.md +5 -0
- package/.changeset/forty-shrimps-fry.md +5 -0
- package/.changeset/grumpy-vans-type.md +5 -0
- package/.changeset/little-spoons-kick.md +7 -0
- package/.changeset/loud-cows-raise.md +7 -0
- package/.changeset/many-buses-allow.md +5 -0
- package/.changeset/poor-eels-punch.md +5 -0
- package/.changeset/pre.json +13 -0
- package/.changeset/real-teachers-peel.md +5 -0
- package/.changeset/slimy-chicken-melt.md +5 -0
- package/.changeset/thick-books-grin.md +5 -0
- package/.changeset/tough-rockets-allow.md +5 -0
- package/.changeset/tricky-tables-shave.md +5 -0
- package/.changeset/warm-ties-sit.md +7 -0
- package/CHANGELOG.md +40 -0
- package/__cjs/cache/core/cache.cjs +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +4 -4
- package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/core/ApolloClient.cjs +3 -3
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +4 -4
- package/__cjs/core/LocalState.cjs +2 -2
- package/__cjs/core/ObservableQuery.cjs +15 -12
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/QueryManager.cjs +57 -35
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +3 -3
- package/__cjs/core/types.d.cts +32 -0
- package/__cjs/invariantErrorCodes.cjs +57 -77
- package/__cjs/link/core/ApolloLink.cjs +2 -2
- package/__cjs/link/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/createHttpLink.cjs +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
- package/__cjs/link/http/serializeFetchParameter.cjs +1 -1
- package/__cjs/link/persisted-queries/index.cjs +2 -2
- package/__cjs/link/utils/validateOperation.cjs +1 -1
- package/__cjs/masking/maskDefinition.cjs +2 -2
- package/__cjs/masking/maskFragment.cjs +2 -2
- package/__cjs/masking/maskOperation.cjs +1 -1
- package/__cjs/masking/utils.cjs +1 -1
- package/__cjs/react/context/ApolloConsumer.cjs +1 -1
- package/__cjs/react/context/ApolloContext.cjs +1 -1
- package/__cjs/react/context/ApolloContext.cjs.map +1 -1
- package/__cjs/react/context/ApolloContext.d.cts +2 -2
- package/__cjs/react/context/ApolloProvider.cjs +1 -1
- package/__cjs/react/hooks/internal/wrapHook.cjs +26 -5
- package/__cjs/react/hooks/internal/wrapHook.cjs.map +1 -1
- package/__cjs/react/hooks/internal/wrapHook.d.cts +3 -1
- package/__cjs/react/hooks/useMutation.cjs +14 -19
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +4 -4
- package/__cjs/react/hooks/useQuery.cjs +82 -187
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +4 -0
- package/__cjs/react/hooks/useSubscription.cjs +8 -57
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.d.cts +6 -42
- package/__cjs/react/hooks/useSuspenseQuery.cjs +2 -2
- package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
- package/__cjs/react/internal/index.cjs +3 -1
- package/__cjs/react/internal/index.cjs.map +1 -1
- package/__cjs/react/internal/index.d.cts +1 -0
- package/__cjs/react/ssr/getDataFromTree.cjs +43 -12
- package/__cjs/react/ssr/getDataFromTree.cjs.map +1 -1
- package/__cjs/react/ssr/getDataFromTree.d.cts +5 -0
- package/__cjs/react/ssr/index.cjs +1 -3
- package/__cjs/react/ssr/index.cjs.map +1 -1
- package/__cjs/react/ssr/index.d.cts +0 -1
- package/__cjs/react/ssr/useSSRQuery.cjs +60 -0
- package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -0
- package/__cjs/react/ssr/useSSRQuery.d.cts +5 -0
- package/__cjs/react/types/deprecated.d.cts +1 -1
- package/__cjs/react/types/types.documentation.d.cts +4 -12
- package/__cjs/testing/matchers/index.cjs +2 -0
- package/__cjs/testing/matchers/index.cjs.map +1 -1
- package/__cjs/testing/matchers/toEmitStrictTyped.cjs +42 -0
- package/__cjs/testing/matchers/toEmitStrictTyped.cjs.map +1 -0
- package/__cjs/testing/matchers/toEmitStrictTyped.d.cts +7 -0
- package/__cjs/testing/matchers/toEqualStrictTyped.cjs +2 -20
- package/__cjs/testing/matchers/toEqualStrictTyped.cjs.map +1 -1
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs +23 -0
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs.map +1 -0
- package/__cjs/testing/matchers/utils/getSerializableProperties.d.cts +2 -0
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.d.cts +1 -1
- package/cache/core/cache.js +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/writeToStore.js +4 -4
- package/core/ApolloClient.d.ts +4 -4
- package/core/ApolloClient.js +3 -3
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.js +2 -2
- package/core/ObservableQuery.js +15 -12
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.d.ts +3 -3
- package/core/QueryManager.js +58 -36
- package/core/QueryManager.js.map +1 -1
- package/core/types.d.ts +32 -0
- package/invariantErrorCodes.js +57 -77
- package/link/core/ApolloLink.js +2 -2
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.js +1 -1
- package/link/http/parseAndCheckHttpResponse.js +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.js +2 -2
- package/link/utils/validateOperation.js +1 -1
- package/masking/maskDefinition.js +2 -2
- package/masking/maskFragment.js +2 -2
- package/masking/maskOperation.js +1 -1
- package/masking/utils.js +1 -1
- package/package.json +1 -1
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloContext.d.ts +2 -2
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/hooks/internal/wrapHook.d.ts +3 -1
- package/react/hooks/internal/wrapHook.js +24 -5
- package/react/hooks/internal/wrapHook.js.map +1 -1
- package/react/hooks/useMutation.d.ts +4 -4
- package/react/hooks/useMutation.js +14 -19
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +4 -0
- package/react/hooks/useQuery.js +83 -188
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +6 -42
- package/react/hooks/useSubscription.js +7 -53
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +2 -2
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/internal/index.d.ts +1 -0
- package/react/internal/index.js +2 -1
- package/react/internal/index.js.map +1 -1
- package/react/ssr/getDataFromTree.d.ts +5 -0
- package/react/ssr/getDataFromTree.js +43 -12
- package/react/ssr/getDataFromTree.js.map +1 -1
- package/react/ssr/index.d.ts +0 -1
- package/react/ssr/index.js +0 -1
- package/react/ssr/index.js.map +1 -1
- package/react/ssr/useSSRQuery.d.ts +5 -0
- package/react/ssr/useSSRQuery.js +56 -0
- package/react/ssr/useSSRQuery.js.map +1 -0
- package/react/types/deprecated.d.ts +1 -1
- package/react/types/types.documentation.d.ts +4 -12
- package/testing/matchers/index.js +2 -0
- package/testing/matchers/index.js.map +1 -1
- package/testing/matchers/toEmitStrictTyped.d.ts +7 -0
- package/testing/matchers/toEmitStrictTyped.js +38 -0
- package/testing/matchers/toEmitStrictTyped.js.map +1 -0
- package/testing/matchers/toEqualStrictTyped.js +1 -19
- package/testing/matchers/toEqualStrictTyped.js.map +1 -1
- package/testing/matchers/utils/getSerializableProperties.d.ts +2 -0
- package/testing/matchers/utils/getSerializableProperties.js +20 -0
- package/testing/matchers/utils/getSerializableProperties.js.map +1 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/__cjs/react/ssr/RenderPromises.cjs +0 -104
- package/__cjs/react/ssr/RenderPromises.cjs.map +0 -1
- package/__cjs/react/ssr/RenderPromises.d.cts +0 -25
- package/react/ssr/RenderPromises.d.ts +0 -25
- package/react/ssr/RenderPromises.js +0 -100
- package/react/ssr/RenderPromises.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApolloContext.cjs","sources":["../../../../src/react/context/ApolloContext.ts"],"sourcesContent":["import type * as ReactTypes from \"react\";\nimport * as React from \"react\";\n\nimport type { ApolloClient } from \"@apollo/client/core\";\nimport type {
|
|
1
|
+
{"version":3,"file":"ApolloContext.cjs","sources":["../../../../src/react/context/ApolloContext.ts"],"sourcesContent":["import type * as ReactTypes from \"react\";\nimport * as React from \"react\";\n\nimport type { ApolloClient } from \"@apollo/client/core\";\nimport type {\n HookWrappers,\n wrapperSymbol,\n} from \"@apollo/client/react/internal\";\nimport { invariant } from \"@apollo/client/utilities/invariant\";\n\nexport interface ApolloContextValue {\n client?: ApolloClient;\n [wrapperSymbol]?: HookWrappers;\n}\n\n// To make sure Apollo Client doesn't create more than one React context\n// (which can lead to problems like having an Apollo Client instance added\n// in one context, then attempting to retrieve it from another different\n// context), a single Apollo context is created and tracked in global state.\nconst contextKey = Symbol.for(\"__APOLLO_CONTEXT__\");\n\nexport function getApolloContext(): ReactTypes.Context<ApolloContextValue> {\n invariant(\n \"createContext\" in React,\n \"Invoking `getApolloContext` in an environment where `React.createContext` is not available.\\n\" +\n \"The Apollo Client functionality you are trying to use is only available in React Client Components.\\n\" +\n 'Please make sure to add \"use client\" at the top of your file.\\n' +\n // TODO: change to React documentation once React documentation contains information about Client Components\n \"For more information, see https://nextjs.org/docs/getting-started/react-essentials#client-components\"\n );\n\n let context = (React.createContext as any)[\n contextKey\n ] as React.Context<ApolloContextValue>;\n if (!context) {\n Object.defineProperty(React.createContext, contextKey, {\n value: (context = React.createContext<ApolloContextValue>({})),\n enumerable: false,\n writable: false,\n configurable: true,\n });\n context.displayName = \"ApolloContext\";\n }\n return context;\n}\n"],"names":[],"mappings":";;AAqBA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;AApBA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAOA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAOA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA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AS,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA,CAAgB;AAChB;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type * as ReactTypes from "react";
|
|
2
2
|
import type { ApolloClient } from "@apollo/client/core";
|
|
3
|
-
import type {
|
|
3
|
+
import type { HookWrappers, wrapperSymbol } from "@apollo/client/react/internal";
|
|
4
4
|
export interface ApolloContextValue {
|
|
5
5
|
client?: ApolloClient;
|
|
6
|
-
|
|
6
|
+
[wrapperSymbol]?: HookWrappers;
|
|
7
7
|
}
|
|
8
8
|
export declare function getApolloContext(): ReactTypes.Context<ApolloContextValue>;
|
|
9
9
|
//# sourceMappingURL=ApolloContext.d.cts.map
|
|
@@ -14,7 +14,7 @@ const ApolloProvider = ({ client, children, }) => {
|
|
|
14
14
|
client: client || parentContext.client,
|
|
15
15
|
};
|
|
16
16
|
}, [parentContext, client]);
|
|
17
|
-
(0, invariant_1.invariant)(context.client,
|
|
17
|
+
(0, invariant_1.invariant)(context.client, 42);
|
|
18
18
|
return (React.createElement(ApolloContext.Provider, { value: context }, children));
|
|
19
19
|
};
|
|
20
20
|
exports.ApolloProvider = ApolloProvider;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wrapperSymbol = void 0;
|
|
3
4
|
exports.wrapHook = wrapHook;
|
|
4
|
-
const
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const React = tslib_1.__importStar(require("react"));
|
|
7
|
+
// direct import to avoid circular dependency
|
|
8
|
+
const ApolloContext_js_1 = require("../../context/ApolloContext.cjs");
|
|
9
|
+
exports.wrapperSymbol = Symbol.for("apollo.hook.wrappers");
|
|
5
10
|
/**
|
|
6
11
|
* @internal
|
|
7
12
|
*
|
|
@@ -38,9 +43,25 @@ const wrapperSymbol = Symbol.for("apollo.hook.wrappers");
|
|
|
38
43
|
* ```
|
|
39
44
|
*/
|
|
40
45
|
function wrapHook(hookName, useHook, clientOrObsQuery) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
// Priority-wise, the later entries in this array wrap
|
|
47
|
+
// previous entries and could prevent them (and in the end,
|
|
48
|
+
// even the original hook) from running
|
|
49
|
+
const wrapperSources = [
|
|
50
|
+
clientOrObsQuery["queryManager"],
|
|
51
|
+
// if we are a hook (not `preloadQuery`), we are guaranteed to be inside of
|
|
52
|
+
// a React render and can use context
|
|
53
|
+
hookName.startsWith("use") ?
|
|
54
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
55
|
+
React.useContext((0, ApolloContext_js_1.getApolloContext)())
|
|
56
|
+
: undefined,
|
|
57
|
+
];
|
|
58
|
+
let wrapped = useHook;
|
|
59
|
+
for (const source of wrapperSources) {
|
|
60
|
+
const wrapper = source?.[exports.wrapperSymbol]?.[hookName];
|
|
61
|
+
if (wrapper) {
|
|
62
|
+
wrapped = wrapper(wrapped);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return wrapped;
|
|
45
66
|
}
|
|
46
67
|
//# sourceMappingURL=wrapHook.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapHook.cjs","sources":["../../../../../src/react/hooks/internal/wrapHook.ts"],"sourcesContent":["import type { ApolloClient } from \"@apollo/client/core\";\nimport type { ObservableQuery } from \"@apollo/client/core\";\nimport type { createQueryPreloader } from \"@apollo/client/react\";\nimport type {\n useBackgroundQuery,\n useFragment,\n useQuery,\n useQueryRefHandlers,\n useReadQuery,\n useSuspenseFragment,\n useSuspenseQuery,\n} from \"@apollo/client/react/hooks\";\n\nimport type { QueryManager } from \"../../../core/QueryManager.js\";\n\
|
|
1
|
+
{"version":3,"file":"wrapHook.cjs","sources":["../../../../../src/react/hooks/internal/wrapHook.ts"],"sourcesContent":["import * as React from \"react\";\n\nimport type { ApolloClient } from \"@apollo/client/core\";\nimport type { ObservableQuery } from \"@apollo/client/core\";\nimport type { createQueryPreloader } from \"@apollo/client/react\";\nimport type {\n useBackgroundQuery,\n useFragment,\n useQuery,\n useQueryRefHandlers,\n useReadQuery,\n useSuspenseFragment,\n useSuspenseQuery,\n} from \"@apollo/client/react/hooks\";\n\nimport type { QueryManager } from \"../../../core/QueryManager.js\";\n// direct import to avoid circular dependency\nimport { getApolloContext } from \"../../context/ApolloContext.js\";\n\nexport const wrapperSymbol = Symbol.for(\"apollo.hook.wrappers\");\n\ntype FunctionSignature<T> =\n T extends (...args: infer A) => infer R ? (...args: A) => R : never;\n\ninterface WrappableHooks {\n createQueryPreloader: typeof createQueryPreloader;\n useQuery: FunctionSignature<typeof useQuery>;\n useSuspenseQuery: typeof useSuspenseQuery;\n useSuspenseFragment: typeof useSuspenseFragment;\n useBackgroundQuery: typeof useBackgroundQuery;\n useReadQuery: typeof useReadQuery;\n useFragment: typeof useFragment;\n useQueryRefHandlers: typeof useQueryRefHandlers;\n}\n\n/**\n * @internal\n * Can be used to correctly type the [Symbol.for(\"apollo.hook.wrappers\")] property of\n * `QueryManager`, to override/wrap hook functionality.\n */\nexport type HookWrappers = {\n [K in keyof WrappableHooks]?: (\n originalHook: WrappableHooks[K]\n ) => WrappableHooks[K];\n};\n\ninterface QueryManagerWithWrappers extends QueryManager {\n [wrapperSymbol]?: HookWrappers;\n}\n\n/**\n * @internal\n *\n * Makes an Apollo Client hook \"wrappable\".\n * That means that the Apollo Client instance can expose a \"wrapper\" that will be\n * used to wrap the original hook implementation with additional logic.\n * @example\n * ```tsx\n * // this is already done in `@apollo/client` for all wrappable hooks (see `WrappableHooks`)\n * // following this pattern\n * function useQuery() {\n * return wrapHook('useQuery', _useQuery, options.client)(query, options);\n * }\n * function _useQuery(query, options) {\n * // original implementation\n * }\n *\n * // this is what a library like `@apollo/client-react-streaming` would do\n * class ApolloClientWithStreaming extends ApolloClient {\n * constructor(options) {\n * super(options);\n * this.queryManager[Symbol.for(\"apollo.hook.wrappers\")] = {\n * useQuery: (original) => (query, options) => {\n * console.log(\"useQuery was called with options\", options);\n * return original(query, options);\n * }\n * }\n * }\n * }\n *\n * // this will now log the options and then call the original `useQuery`\n * const client = new ApolloClientWithStreaming({ ... });\n * useQuery(query, { client });\n * ```\n */\nexport function wrapHook<Hook extends (...args: any[]) => any>(\n hookName: keyof WrappableHooks,\n useHook: Hook,\n clientOrObsQuery: ObservableQuery<any> | ApolloClient\n): Hook {\n // Priority-wise, the later entries in this array wrap\n // previous entries and could prevent them (and in the end,\n // even the original hook) from running\n const wrapperSources = [\n (\n clientOrObsQuery as unknown as {\n // both `ApolloClient` and `ObservableQuery` have a `queryManager` property\n // but they're both `private`, so we have to cast around for a bit here.\n queryManager: QueryManagerWithWrappers;\n }\n )[\"queryManager\"],\n // if we are a hook (not `preloadQuery`), we are guaranteed to be inside of\n // a React render and can use context\n hookName.startsWith(\"use\") ?\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useContext(getApolloContext())\n : undefined,\n ];\n\n let wrapped = useHook;\n for (const source of wrapperSources) {\n const wrapper = source?.[wrapperSymbol]?.[hookName];\n if (wrapper) {\n wrapped = wrapper(wrapped) as Hook;\n }\n }\n\n return wrapped;\n}\n"],"names":[],"mappings":";;;AAqFA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;AArFA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAgBA,CAAA,EAAA,CAA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@@ -2,9 +2,11 @@ import type { ApolloClient } from "@apollo/client/core";
|
|
|
2
2
|
import type { ObservableQuery } from "@apollo/client/core";
|
|
3
3
|
import type { createQueryPreloader } from "@apollo/client/react";
|
|
4
4
|
import type { useBackgroundQuery, useFragment, useQuery, useQueryRefHandlers, useReadQuery, useSuspenseFragment, useSuspenseQuery } from "@apollo/client/react/hooks";
|
|
5
|
+
export declare const wrapperSymbol: unique symbol;
|
|
6
|
+
type FunctionSignature<T> = T extends (...args: infer A) => infer R ? (...args: A) => R : never;
|
|
5
7
|
interface WrappableHooks {
|
|
6
8
|
createQueryPreloader: typeof createQueryPreloader;
|
|
7
|
-
useQuery: typeof useQuery
|
|
9
|
+
useQuery: FunctionSignature<typeof useQuery>;
|
|
8
10
|
useSuspenseQuery: typeof useSuspenseQuery;
|
|
9
11
|
useSuspenseFragment: typeof useSuspenseFragment;
|
|
10
12
|
useBackgroundQuery: typeof useBackgroundQuery;
|
|
@@ -4,7 +4,6 @@ exports.useMutation = useMutation;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const equality_1 = require("@wry/equality");
|
|
6
6
|
const React = tslib_1.__importStar(require("react"));
|
|
7
|
-
const errors_1 = require("@apollo/client/errors");
|
|
8
7
|
const parser_1 = require("@apollo/client/react/parser");
|
|
9
8
|
const utilities_1 = require("@apollo/client/utilities");
|
|
10
9
|
const useIsomorphicLayoutEffect_js_1 = require("./internal/useIsomorphicLayoutEffect.cjs");
|
|
@@ -59,11 +58,7 @@ const useApolloClient_js_1 = require("./useApolloClient.cjs");
|
|
|
59
58
|
function useMutation(mutation, options) {
|
|
60
59
|
const client = (0, useApolloClient_js_1.useApolloClient)(options?.client);
|
|
61
60
|
(0, parser_1.verifyDocumentType)(mutation, parser_1.DocumentType.Mutation);
|
|
62
|
-
const [result, setResult] = React.useState(
|
|
63
|
-
called: false,
|
|
64
|
-
loading: false,
|
|
65
|
-
client,
|
|
66
|
-
});
|
|
61
|
+
const [result, setResult] = React.useState(() => createInitialResult(client));
|
|
67
62
|
const ref = React.useRef({
|
|
68
63
|
result,
|
|
69
64
|
mutationId: 0,
|
|
@@ -82,8 +77,8 @@ function useMutation(mutation, options) {
|
|
|
82
77
|
if (!ref.current.result.loading && ref.current.isMounted) {
|
|
83
78
|
setResult((ref.current.result = {
|
|
84
79
|
loading: true,
|
|
85
|
-
error:
|
|
86
|
-
data:
|
|
80
|
+
error: undefined,
|
|
81
|
+
data: undefined,
|
|
87
82
|
called: true,
|
|
88
83
|
client,
|
|
89
84
|
}));
|
|
@@ -93,10 +88,7 @@ function useMutation(mutation, options) {
|
|
|
93
88
|
return client
|
|
94
89
|
.mutate(clientOptions)
|
|
95
90
|
.then((response) => {
|
|
96
|
-
const { data,
|
|
97
|
-
const error = errors && errors.length > 0 ?
|
|
98
|
-
new errors_1.CombinedGraphQLErrors(errors)
|
|
99
|
-
: void 0;
|
|
91
|
+
const { data, error } = response;
|
|
100
92
|
const onError = executeOptions.onError || ref.current.options?.onError;
|
|
101
93
|
if (error && onError) {
|
|
102
94
|
onError(error, clientOptions);
|
|
@@ -135,19 +127,13 @@ function useMutation(mutation, options) {
|
|
|
135
127
|
const onError = executeOptions.onError || ref.current.options?.onError;
|
|
136
128
|
if (onError) {
|
|
137
129
|
onError(error, clientOptions);
|
|
138
|
-
// TODO(brian): why are we returning this here???
|
|
139
|
-
return { data: void 0, errors: error };
|
|
140
130
|
}
|
|
141
131
|
throw error;
|
|
142
132
|
});
|
|
143
133
|
}, []);
|
|
144
134
|
const reset = React.useCallback(() => {
|
|
145
135
|
if (ref.current.isMounted) {
|
|
146
|
-
const result =
|
|
147
|
-
called: false,
|
|
148
|
-
loading: false,
|
|
149
|
-
client: ref.current.client,
|
|
150
|
-
};
|
|
136
|
+
const result = createInitialResult(ref.current.client);
|
|
151
137
|
Object.assign(ref.current, { mutationId: 0, result });
|
|
152
138
|
setResult(result);
|
|
153
139
|
}
|
|
@@ -161,4 +147,13 @@ function useMutation(mutation, options) {
|
|
|
161
147
|
}, []);
|
|
162
148
|
return [execute, { reset, ...result }];
|
|
163
149
|
}
|
|
150
|
+
function createInitialResult(client) {
|
|
151
|
+
return {
|
|
152
|
+
data: undefined,
|
|
153
|
+
error: undefined,
|
|
154
|
+
called: false,
|
|
155
|
+
loading: false,
|
|
156
|
+
client,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
164
159
|
//# sourceMappingURL=useMutation.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMutation.cjs","sources":["../../../../src/react/hooks/useMutation.ts"],"sourcesContent":["import type { TypedDocumentNode } from \"@graphql-typed-document-node/core\";\nimport { equal } from \"@wry/equality\";\nimport type { DocumentNode } from \"graphql\";\nimport * as React from \"react\";\n\nimport type {\n ApolloCache,\n ApolloClient,\n DefaultContext,\n ErrorLike,\n ErrorPolicy,\n FetchResult,\n InternalRefetchQueriesInclude,\n MaybeMasked,\n MutationFetchPolicy,\n MutationOptions,\n MutationQueryReducersMap,\n MutationUpdaterFunction,\n OnQueryUpdated,\n OperationVariables,\n Unmasked,\n} from \"@apollo/client/core\";\nimport { CombinedGraphQLErrors } from \"@apollo/client/errors\";\nimport { DocumentType, verifyDocumentType } from \"@apollo/client/react/parser\";\nimport type { NoInfer } from \"@apollo/client/utilities\";\nimport { mergeOptions } from \"@apollo/client/utilities\";\n\nimport type { IgnoreModifier } from \"../../cache/core/types/common.js\";\n\nimport { useIsomorphicLayoutEffect } from \"./internal/useIsomorphicLayoutEffect.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\nexport declare namespace useMutation {\n export interface Options<\n TData = unknown,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache = ApolloCache,\n > {\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#optimisticResponse:member} */\n optimisticResponse?:\n | Unmasked<NoInfer<TData>>\n | ((\n vars: TVariables,\n { IGNORE }: { IGNORE: IgnoreModifier }\n ) => Unmasked<NoInfer<TData>> | IgnoreModifier);\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#updateQueries:member} */\n updateQueries?: MutationQueryReducersMap<TData>;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#refetchQueries:member} */\n refetchQueries?:\n | ((\n result: FetchResult<Unmasked<TData>>\n ) => InternalRefetchQueriesInclude)\n | InternalRefetchQueriesInclude;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#awaitRefetchQueries:member} */\n awaitRefetchQueries?: boolean;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#update:member} */\n update?: MutationUpdaterFunction<TData, TVariables, TContext, TCache>;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#onQueryUpdated:member} */\n onQueryUpdated?: OnQueryUpdated<any>;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#errorPolicy:member} */\n errorPolicy?: ErrorPolicy;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#variables:member} */\n variables?: TVariables;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#context:member} */\n context?: TContext;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#fetchPolicy:member} */\n fetchPolicy?: MutationFetchPolicy;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#keepRootFields:member} */\n keepRootFields?: boolean;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#client:member} */\n client?: ApolloClient;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#notifyOnNetworkStatusChange:member} */\n notifyOnNetworkStatusChange?: boolean;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#onCompleted:member} */\n onCompleted?: (\n data: MaybeMasked<TData>,\n clientOptions?: Options<TData, TVariables, TContext, TCache>\n ) => void;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#onError:member} */\n onError?: (\n error: ErrorLike,\n clientOptions?: Options<TData, TVariables, TContext, TCache>\n ) => void;\n }\n\n export interface Result<TData = unknown> {\n /** {@inheritDoc @apollo/client!MutationResultDocumentation#data:member} */\n data?: MaybeMasked<TData> | null;\n\n /** {@inheritDoc @apollo/client!MutationResultDocumentation#error:member} */\n error?: ErrorLike;\n\n /** {@inheritDoc @apollo/client!MutationResultDocumentation#loading:member} */\n loading: boolean;\n\n /** {@inheritDoc @apollo/client!MutationResultDocumentation#called:member} */\n called: boolean;\n\n /** {@inheritDoc @apollo/client!MutationResultDocumentation#client:member} */\n client: ApolloClient;\n\n /** {@inheritDoc @apollo/client!MutationResultDocumentation#reset:member} */\n reset: () => void;\n }\n\n export type ResultTuple<\n TData,\n TVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache = ApolloCache,\n > = [\n mutate: (\n options?: MutationFunctionOptions<TData, TVariables, TContext, TCache>\n // TODO This FetchResult<TData> seems strange here, as opposed to an\n // ApolloQueryResult<TData>\n ) => Promise<FetchResult<MaybeMasked<TData>>>,\n result: Result<TData>,\n ];\n\n export interface MutationFunctionOptions<\n TData = unknown,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache = ApolloCache,\n > extends Options<TData, TVariables, TContext, TCache> {\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#mutation:member} */\n // TODO: Remove this option. We shouldn't allow the mutation to be overridden\n // in the mutation function\n mutation?: DocumentNode | TypedDocumentNode<TData, TVariables>;\n }\n}\n\n/**\n *\n *\n * > Refer to the [Mutations](https://www.apollographql.com/docs/react/data/mutations/) section for a more in-depth overview of `useMutation`.\n *\n * @example\n * ```jsx\n * import { gql, useMutation } from '@apollo/client';\n *\n * const ADD_TODO = gql`\n * mutation AddTodo($type: String!) {\n * addTodo(type: $type) {\n * id\n * type\n * }\n * }\n * `;\n *\n * function AddTodo() {\n * let input;\n * const [addTodo, { data }] = useMutation(ADD_TODO);\n *\n * return (\n * <div>\n * <form\n * onSubmit={e => {\n * e.preventDefault();\n * addTodo({ variables: { type: input.value } });\n * input.value = '';\n * }}\n * >\n * <input\n * ref={node => {\n * input = node;\n * }}\n * />\n * <button type=\"submit\">Add Todo</button>\n * </form>\n * </div>\n * );\n * }\n * ```\n * @since 3.0.0\n * @param mutation - A GraphQL mutation document parsed into an AST by `gql`.\n * @param options - Options to control how the mutation is executed.\n * @returns A tuple in the form of `[mutate, result]`\n */\nexport function useMutation<\n TData = unknown,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache = ApolloCache,\n>(\n mutation: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: useMutation.Options<\n NoInfer<TData>,\n NoInfer<TVariables>,\n TContext,\n TCache\n >\n): useMutation.ResultTuple<TData, TVariables, TContext, TCache> {\n const client = useApolloClient(options?.client);\n verifyDocumentType(mutation, DocumentType.Mutation);\n const [result, setResult] = React.useState<\n Omit<useMutation.Result<TData>, \"reset\">\n >({\n called: false,\n loading: false,\n client,\n });\n\n const ref = React.useRef({\n result,\n mutationId: 0,\n isMounted: true,\n client,\n mutation,\n options,\n });\n\n useIsomorphicLayoutEffect(() => {\n Object.assign(ref.current, { client, options, mutation });\n });\n\n const execute = React.useCallback(\n (\n executeOptions: useMutation.MutationFunctionOptions<\n TData,\n TVariables,\n TContext,\n TCache\n > = {}\n ) => {\n const { options, mutation } = ref.current;\n const baseOptions = { ...options, mutation };\n const client = executeOptions.client || ref.current.client;\n\n if (!ref.current.result.loading && ref.current.isMounted) {\n setResult(\n (ref.current.result = {\n loading: true,\n error: void 0,\n data: void 0,\n called: true,\n client,\n })\n );\n }\n\n const mutationId = ++ref.current.mutationId;\n const clientOptions = mergeOptions(baseOptions, executeOptions);\n\n return client\n .mutate(clientOptions as MutationOptions<TData, OperationVariables>)\n .then(\n (response) => {\n const { data, errors } = response;\n const error =\n errors && errors.length > 0 ?\n new CombinedGraphQLErrors(errors)\n : void 0;\n\n const onError =\n executeOptions.onError || ref.current.options?.onError;\n\n if (error && onError) {\n onError(error, clientOptions);\n }\n\n if (mutationId === ref.current.mutationId) {\n const result = {\n called: true,\n loading: false,\n data,\n error,\n client,\n };\n\n if (ref.current.isMounted && !equal(ref.current.result, result)) {\n setResult((ref.current.result = result));\n }\n }\n\n const onCompleted =\n executeOptions.onCompleted || ref.current.options?.onCompleted;\n\n if (!error) {\n onCompleted?.(response.data!, clientOptions);\n }\n\n return response;\n },\n (error) => {\n if (\n mutationId === ref.current.mutationId &&\n ref.current.isMounted\n ) {\n const result = {\n loading: false,\n error,\n data: void 0,\n called: true,\n client,\n };\n\n if (!equal(ref.current.result, result)) {\n setResult((ref.current.result = result));\n }\n }\n\n const onError =\n executeOptions.onError || ref.current.options?.onError;\n\n if (onError) {\n onError(error, clientOptions);\n\n // TODO(brian): why are we returning this here???\n return { data: void 0, errors: error };\n }\n\n throw error;\n }\n );\n },\n []\n );\n\n const reset = React.useCallback(() => {\n if (ref.current.isMounted) {\n const result = {\n called: false,\n loading: false,\n client: ref.current.client,\n };\n Object.assign(ref.current, { mutationId: 0, result });\n setResult(result);\n }\n }, []);\n\n React.useEffect(() => {\n const current = ref.current;\n current.isMounted = true;\n\n return () => {\n current.isMounted = false;\n };\n }, []);\n\n return [execute, { reset, ...result }];\n}\n"],"names":[],"mappings":";;AAkMA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;AAjMA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAEA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,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CAA+B;QAC3B,CAAJ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAC,CAAZ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAwB,CAAxB,CAAA,CAAA,CAA4B;QAExB,CAAJ,CAAA,CAAA,CAAA,CAAA,EAAW,CAAX,EAAc,CAAd,EAAA;YACM,CAAN,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAC,CAAd,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAA0B,CAA1B,CAAA,CAAA,CAAA,CAA+B;QAC3B,CAAC;IACH,CAAC,EAAE,CAAL,CAAO,CAAC;IAEN,CAAF,CAAA,CAAA,CAAA,CAAA,EAAS,CAAC,CAAV,CAAA,CAAA,CAAA,CAAA,CAAA,CAAiB,EAAE,EAAE,CAArB,CAAA,CAAA,CAAA,CAA0B,EAAE,CAA5B,CAAA,CAA+B,CAA/B,CAAA,CAAA,CAAA,CAAA,EAAA,CAAuC,CAAC;AACxC;"}
|
|
1
|
+
{"version":3,"file":"useMutation.cjs","sources":["../../../../src/react/hooks/useMutation.ts"],"sourcesContent":["import type { TypedDocumentNode } from \"@graphql-typed-document-node/core\";\nimport { equal } from \"@wry/equality\";\nimport type { DocumentNode } from \"graphql\";\nimport * as React from \"react\";\n\nimport type {\n ApolloCache,\n ApolloClient,\n DefaultContext,\n ErrorLike,\n ErrorPolicy,\n FetchResult,\n InternalRefetchQueriesInclude,\n MaybeMasked,\n MutateResult,\n MutationFetchPolicy,\n MutationOptions,\n MutationQueryReducersMap,\n MutationUpdaterFunction,\n OnQueryUpdated,\n OperationVariables,\n Unmasked,\n} from \"@apollo/client/core\";\nimport { DocumentType, verifyDocumentType } from \"@apollo/client/react/parser\";\nimport type { NoInfer } from \"@apollo/client/utilities\";\nimport { mergeOptions } from \"@apollo/client/utilities\";\n\nimport type { IgnoreModifier } from \"../../cache/core/types/common.js\";\n\nimport { useIsomorphicLayoutEffect } from \"./internal/useIsomorphicLayoutEffect.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\nexport declare namespace useMutation {\n export interface Options<\n TData = unknown,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache = ApolloCache,\n > {\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#optimisticResponse:member} */\n optimisticResponse?:\n | Unmasked<NoInfer<TData>>\n | ((\n vars: TVariables,\n { IGNORE }: { IGNORE: IgnoreModifier }\n ) => Unmasked<NoInfer<TData>> | IgnoreModifier);\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#updateQueries:member} */\n updateQueries?: MutationQueryReducersMap<TData>;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#refetchQueries:member} */\n refetchQueries?:\n | ((\n result: FetchResult<Unmasked<TData>>\n ) => InternalRefetchQueriesInclude)\n | InternalRefetchQueriesInclude;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#awaitRefetchQueries:member} */\n awaitRefetchQueries?: boolean;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#update:member} */\n update?: MutationUpdaterFunction<TData, TVariables, TContext, TCache>;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#onQueryUpdated:member} */\n onQueryUpdated?: OnQueryUpdated<any>;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#errorPolicy:member} */\n errorPolicy?: ErrorPolicy;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#variables:member} */\n variables?: TVariables;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#context:member} */\n context?: TContext;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#fetchPolicy:member} */\n fetchPolicy?: MutationFetchPolicy;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#keepRootFields:member} */\n keepRootFields?: boolean;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#client:member} */\n client?: ApolloClient;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#notifyOnNetworkStatusChange:member} */\n notifyOnNetworkStatusChange?: boolean;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#onCompleted:member} */\n onCompleted?: (\n data: MaybeMasked<TData>,\n clientOptions?: Options<TData, TVariables, TContext, TCache>\n ) => void;\n\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#onError:member} */\n onError?: (\n error: ErrorLike,\n clientOptions?: Options<TData, TVariables, TContext, TCache>\n ) => void;\n }\n\n export interface Result<TData = unknown> {\n /** {@inheritDoc @apollo/client!MutationResultDocumentation#data:member} */\n data: MaybeMasked<TData> | null | undefined;\n\n /** {@inheritDoc @apollo/client!MutationResultDocumentation#error:member} */\n error: ErrorLike | undefined;\n\n /** {@inheritDoc @apollo/client!MutationResultDocumentation#loading:member} */\n loading: boolean;\n\n /** {@inheritDoc @apollo/client!MutationResultDocumentation#called:member} */\n called: boolean;\n\n /** {@inheritDoc @apollo/client!MutationResultDocumentation#client:member} */\n client: ApolloClient;\n\n /** {@inheritDoc @apollo/client!MutationResultDocumentation#reset:member} */\n reset: () => void;\n }\n\n export type ResultTuple<\n TData,\n TVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache = ApolloCache,\n > = [\n mutate: (\n options?: MutationFunctionOptions<TData, TVariables, TContext, TCache>\n ) => Promise<MutateResult<MaybeMasked<TData>>>,\n result: Result<TData>,\n ];\n\n export interface MutationFunctionOptions<\n TData = unknown,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache = ApolloCache,\n > extends Options<TData, TVariables, TContext, TCache> {\n /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#mutation:member} */\n // TODO: Remove this option. We shouldn't allow the mutation to be overridden\n // in the mutation function\n mutation?: DocumentNode | TypedDocumentNode<TData, TVariables>;\n }\n}\n\n/**\n *\n *\n * > Refer to the [Mutations](https://www.apollographql.com/docs/react/data/mutations/) section for a more in-depth overview of `useMutation`.\n *\n * @example\n * ```jsx\n * import { gql, useMutation } from '@apollo/client';\n *\n * const ADD_TODO = gql`\n * mutation AddTodo($type: String!) {\n * addTodo(type: $type) {\n * id\n * type\n * }\n * }\n * `;\n *\n * function AddTodo() {\n * let input;\n * const [addTodo, { data }] = useMutation(ADD_TODO);\n *\n * return (\n * <div>\n * <form\n * onSubmit={e => {\n * e.preventDefault();\n * addTodo({ variables: { type: input.value } });\n * input.value = '';\n * }}\n * >\n * <input\n * ref={node => {\n * input = node;\n * }}\n * />\n * <button type=\"submit\">Add Todo</button>\n * </form>\n * </div>\n * );\n * }\n * ```\n * @since 3.0.0\n * @param mutation - A GraphQL mutation document parsed into an AST by `gql`.\n * @param options - Options to control how the mutation is executed.\n * @returns A tuple in the form of `[mutate, result]`\n */\nexport function useMutation<\n TData = unknown,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache = ApolloCache,\n>(\n mutation: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: useMutation.Options<\n NoInfer<TData>,\n NoInfer<TVariables>,\n TContext,\n TCache\n >\n): useMutation.ResultTuple<TData, TVariables, TContext, TCache> {\n const client = useApolloClient(options?.client);\n verifyDocumentType(mutation, DocumentType.Mutation);\n const [result, setResult] = React.useState<\n Omit<useMutation.Result<TData>, \"reset\">\n >(() => createInitialResult(client));\n\n const ref = React.useRef({\n result,\n mutationId: 0,\n isMounted: true,\n client,\n mutation,\n options,\n });\n\n useIsomorphicLayoutEffect(() => {\n Object.assign(ref.current, { client, options, mutation });\n });\n\n const execute = React.useCallback(\n (\n executeOptions: useMutation.MutationFunctionOptions<\n TData,\n TVariables,\n TContext,\n TCache\n > = {}\n ) => {\n const { options, mutation } = ref.current;\n const baseOptions = { ...options, mutation };\n const client = executeOptions.client || ref.current.client;\n\n if (!ref.current.result.loading && ref.current.isMounted) {\n setResult(\n (ref.current.result = {\n loading: true,\n error: undefined,\n data: undefined,\n called: true,\n client,\n })\n );\n }\n\n const mutationId = ++ref.current.mutationId;\n const clientOptions = mergeOptions(baseOptions, executeOptions);\n\n return client\n .mutate(clientOptions as MutationOptions<TData, OperationVariables>)\n .then(\n (response) => {\n const { data, error } = response;\n\n const onError =\n executeOptions.onError || ref.current.options?.onError;\n\n if (error && onError) {\n onError(error, clientOptions);\n }\n\n if (mutationId === ref.current.mutationId) {\n const result = {\n called: true,\n loading: false,\n data,\n error,\n client,\n };\n\n if (ref.current.isMounted && !equal(ref.current.result, result)) {\n setResult((ref.current.result = result));\n }\n }\n\n const onCompleted =\n executeOptions.onCompleted || ref.current.options?.onCompleted;\n\n if (!error) {\n onCompleted?.(response.data!, clientOptions);\n }\n\n return response;\n },\n (error) => {\n if (\n mutationId === ref.current.mutationId &&\n ref.current.isMounted\n ) {\n const result = {\n loading: false,\n error,\n data: void 0,\n called: true,\n client,\n };\n\n if (!equal(ref.current.result, result)) {\n setResult((ref.current.result = result));\n }\n }\n\n const onError =\n executeOptions.onError || ref.current.options?.onError;\n\n if (onError) {\n onError(error, clientOptions);\n }\n\n throw error;\n }\n );\n },\n []\n );\n\n const reset = React.useCallback(() => {\n if (ref.current.isMounted) {\n const result = createInitialResult(ref.current.client);\n Object.assign(ref.current, { mutationId: 0, result });\n setResult(result);\n }\n }, []);\n\n React.useEffect(() => {\n const current = ref.current;\n current.isMounted = true;\n\n return () => {\n current.isMounted = false;\n };\n }, []);\n\n return [execute, { reset, ...result }];\n}\n\nfunction createInitialResult(client: ApolloClient) {\n return {\n data: undefined,\n error: undefined,\n called: false,\n loading: false,\n client,\n };\n}\n"],"names":[],"mappings":";;AAgMA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;AA/LA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,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,CAAA,CAAA,CAAA,CAAA,CAAU,EAAE,CAAZ,CAAA,CAAA,CAAA,CAAiB;QACb,CAAJ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,EAAE,CAAb,CAAA,CAAA,CAAA,CAAkB;QACd,CAAJ,CAAA,CAAA,CAAA,CAAA,CAAU;IACV,CAAG;AACH;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TypedDocumentNode } from "@graphql-typed-document-node/core";
|
|
2
2
|
import type { DocumentNode } from "graphql";
|
|
3
|
-
import type { ApolloCache, ApolloClient, DefaultContext, ErrorLike, ErrorPolicy, FetchResult, InternalRefetchQueriesInclude, MaybeMasked, MutationFetchPolicy, MutationQueryReducersMap, MutationUpdaterFunction, OnQueryUpdated, OperationVariables, Unmasked } from "@apollo/client/core";
|
|
3
|
+
import type { ApolloCache, ApolloClient, DefaultContext, ErrorLike, ErrorPolicy, FetchResult, InternalRefetchQueriesInclude, MaybeMasked, MutateResult, MutationFetchPolicy, MutationQueryReducersMap, MutationUpdaterFunction, OnQueryUpdated, OperationVariables, Unmasked } from "@apollo/client/core";
|
|
4
4
|
import type { NoInfer } from "@apollo/client/utilities";
|
|
5
5
|
import type { IgnoreModifier } from "../../cache/core/types/common.cjs";
|
|
6
6
|
export declare namespace useMutation {
|
|
@@ -156,13 +156,13 @@ export declare namespace useMutation {
|
|
|
156
156
|
/**
|
|
157
157
|
* The data returned from your mutation. Can be `undefined` if `ignoreResults` is `true`.
|
|
158
158
|
*/
|
|
159
|
-
data
|
|
159
|
+
data: MaybeMasked<TData> | null | undefined;
|
|
160
160
|
/**
|
|
161
161
|
* If the mutation produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.
|
|
162
162
|
*
|
|
163
163
|
* For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
|
|
164
164
|
*/
|
|
165
|
-
error
|
|
165
|
+
error: ErrorLike | undefined;
|
|
166
166
|
/**
|
|
167
167
|
* If `true`, the mutation is currently in flight.
|
|
168
168
|
*/
|
|
@@ -183,7 +183,7 @@ export declare namespace useMutation {
|
|
|
183
183
|
reset: () => void;
|
|
184
184
|
}
|
|
185
185
|
type ResultTuple<TData, TVariables, TContext = DefaultContext, TCache extends ApolloCache = ApolloCache> = [
|
|
186
|
-
mutate: (options?: MutationFunctionOptions<TData, TVariables, TContext, TCache>) => Promise<
|
|
186
|
+
mutate: (options?: MutationFunctionOptions<TData, TVariables, TContext, TCache>) => Promise<MutateResult<MaybeMasked<TData>>>,
|
|
187
187
|
result: Result<TData>
|
|
188
188
|
];
|
|
189
189
|
interface MutationFunctionOptions<TData = unknown, TVariables = OperationVariables, TContext = DefaultContext, TCache extends ApolloCache = ApolloCache> extends Options<TData, TVariables, TContext, TCache> {
|