Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Custom client on Mutations #1943

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Mutation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export interface MutationProps<TData = any, TVariables = OperationVariables> {
onCompleted?: (data: TData) => void;
onError?: (error: ApolloError) => void;
context?: Record<string, any>;
client?: ApolloClient<Object>;
}

export interface MutationState<TData = any> {
Expand Down Expand Up @@ -114,7 +115,11 @@ class Mutation<TData = any, TVariables = OperationVariables> extends React.Compo
super(props, context);

this.verifyContext(context);
this.client = context.client;
this.client = props.client || context.client;
invariant(
!!this.client,
`Could not find "client" in the context of Query or as passed props. Wrap the root component in an <ApolloProvider>`,
);

this.verifyDocumentIsMutation(props.mutation);

Expand Down