From 39215877e990e9cd50962a63af7615ff6cedbb45 Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Wed, 4 Dec 2019 15:49:44 +0100 Subject: [PATCH] feat(useMutation): overrideOptions --- packages/docs/src/api/use-mutation.md | 2 +- packages/vue-apollo-composable/src/useMutation.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/docs/src/api/use-mutation.md b/packages/docs/src/api/use-mutation.md index a71a9d9..77561b6 100644 --- a/packages/docs/src/api/use-mutation.md +++ b/packages/docs/src/api/use-mutation.md @@ -40,7 +40,7 @@ ## Return -- `mutate`: call the mutation with this function. +- `mutate(variables, overrideOptions)`: call the mutation with this function. - `loading`: boolean `Ref` tracking the progress of the mutation. diff --git a/packages/vue-apollo-composable/src/useMutation.ts b/packages/vue-apollo-composable/src/useMutation.ts index 50bc6ff..2e5dc37 100644 --- a/packages/vue-apollo-composable/src/useMutation.ts +++ b/packages/vue-apollo-composable/src/useMutation.ts @@ -34,7 +34,7 @@ export function useMutation< // Apollo Client const { resolveClient } = useApolloClient() - async function mutate (variables: TVariables = null) { + async function mutate (variables: TVariables = null, overrideOptions: Omit) { let currentDocument: DocumentNode if (typeof document === 'function') { currentDocument = document() @@ -56,6 +56,7 @@ export function useMutation< const result = await client.mutate({ mutation: currentDocument, ...currentOptions, + ...overrideOptions, variables: { ...variables || {}, ...currentOptions.variables || {},