feat(useMutation): overrideOptions

This commit is contained in:
Guillaume Chau
2019-12-04 15:49:44 +01:00
parent 8f3502f578
commit 39215877e9
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -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.
@@ -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<UseMutationOptions, 'variables'>) {
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 || {},