Skip to content

Commit e2b51b3

Browse files
authored
Disallow mutation option in mutate callback returned from useMutation (#12802)
1 parent 1ca73d8 commit e2b51b3

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

.api-reports/api-report-react.api.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,9 +632,7 @@ export namespace useMutation {
632632
}
633633
]) => Promise<ApolloClient.MutateResult<MaybeMasked<TData>>>;
634634
// (undocumented)
635-
export type MutationFunctionOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables, TCache extends ApolloCache = ApolloCache> = Options<TData, TVariables, TCache> & {
636-
mutation?: DocumentNode_2 | TypedDocumentNode<TData, TVariables>;
637-
};
635+
export type MutationFunctionOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables, TCache extends ApolloCache = ApolloCache> = Options<TData, TVariables, TCache>;
638636
// (undocumented)
639637
export interface Options<TData = unknown, TVariables extends OperationVariables = OperationVariables, TCache extends ApolloCache = ApolloCache, TConfiguredVariables extends Partial<TVariables> = Partial<TVariables>> {
640638
awaitRefetchQueries?: boolean;

.changeset/heavy-ways-call.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@apollo/client": major
3+
---
4+
5+
Disallow the `mutation` option for the `mutate` function returned from `useMutation`.

src/react/hooks/useMutation.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,7 @@ export declare namespace useMutation {
157157
TData = unknown,
158158
TVariables extends OperationVariables = OperationVariables,
159159
TCache extends ApolloCache = ApolloCache,
160-
> = Options<TData, TVariables, TCache> & {
161-
/** {@inheritDoc @apollo/client!MutationOptionsDocumentation#mutation:member} */
162-
// TODO: Remove this option. We shouldn't allow the mutation to be overridden
163-
// in the mutation function
164-
mutation?: DocumentNode | TypedDocumentNode<TData, TVariables>;
165-
};
160+
> = Options<TData, TVariables, TCache>;
166161

167162
export namespace DocumentationTypes {
168163
/** {@inheritDoc @apollo/client!useMutation:function(1)} */

0 commit comments

Comments
 (0)