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) - use executeMutation over mutation (#1732)

* use executeMutation over mutation

* remove commented out line

authored by

Jovi De Croock and committed by
GitHub
be364fb8 8825865d

+23 -16
+5
.changeset/popular-sheep-itch.md
··· 1 + --- 2 + '@urql/svelte': patch 3 + --- 4 + 5 + Use client.executeMutation rather than client.mutation
+3 -7
packages/svelte-urql/src/operations.test.ts
··· 1 - import { makeSubject, pipe, take, toPromise } from 'wonka'; 1 + import { makeSubject } from 'wonka'; 2 2 import { createClient } from '@urql/core'; 3 3 import { operationStore } from './operationStore'; 4 4 import { query, subscription, mutation } from './operations'; ··· 241 241 const subscriber = jest.fn(); 242 242 const subject = makeSubject<any>(); 243 243 const clientMutation = jest 244 - .spyOn(client, 'mutation') 245 - .mockImplementation((): any => ({ 246 - toPromise() { 247 - return pipe(subject.source, take(1), toPromise); 248 - }, 249 - })); 244 + .spyOn(client, 'executeMutation') 245 + .mockImplementation((): any => subject.source); 250 246 251 247 const store = operationStore('mutation { test }', { test: false }); 252 248 store.subscribe(subscriber);
+15 -9
packages/svelte-urql/src/operations.ts
··· 19 19 fromValue, 20 20 switchMap, 21 21 subscribe, 22 + toPromise, 23 + take, 22 24 } from 'wonka'; 23 25 24 26 import { OperationStore, operationStore } from './operationStore'; ··· 184 186 185 187 _markStoreUpdate(update); 186 188 store.set(update); 187 - return client 188 - .mutation(store.query, store.variables as any, store.context) 189 - .toPromise() 190 - .then(result => { 191 - const update = { fetching: false, ...result }; 192 - _markStoreUpdate(update); 193 - store.set(update); 194 - return store; 195 - }); 189 + return pipe( 190 + client.executeMutation( 191 + createRequest(store.query, store.variables || {}), 192 + store.context 193 + ), 194 + take(1), 195 + toPromise 196 + ).then(result => { 197 + const update = { fetching: false, ...result }; 198 + _markStoreUpdate(update); 199 + store.set(update); 200 + return store; 201 + }); 196 202 }; 197 203 }