Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Svelte: Update mutate to have an options argument for consistency (#705)

authored by

Phil Plückthun and committed by
GitHub
7b0d18b5 17b22479

+15 -4
+5
.changeset/young-eyes-call.md
··· 1 + --- 2 + '@urql/svelte': minor 3 + --- 4 + 5 + Update `mutate()` API to accept an options argument, instead of separate arguments, to increase consistency
+10 -4
packages/svelte-urql/src/operations/mutate.ts
··· 3 3 4 4 import { getClient } from '../context'; 5 5 6 + export interface MutationArguments<V> { 7 + query: string | DocumentNode; 8 + variables?: V; 9 + context?: Partial<OperationContext>; 10 + } 11 + 6 12 export const mutate = <T = any, V = object>( 7 - query: string | DocumentNode, 8 - variables?: V, 9 - context?: Partial<OperationContext> 13 + args: MutationArguments<V> 10 14 ): PromiseLike<OperationResult<T>> => { 11 15 const client = getClient(); 12 16 let promise: Promise<OperationResult<T>>; ··· 14 18 return { 15 19 then(onValue) { 16 20 if (!promise) { 17 - promise = client.mutation(query, variables as any, context).toPromise(); 21 + promise = client 22 + .mutation(args.query, args.variables as any, args.context) 23 + .toPromise(); 18 24 } 19 25 20 26 return promise.then(onValue);