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

(svelte) - Promise mutation result (#758)

Changed files
+9 -15
.changeset
packages
svelte-urql
src
operations
+5
.changeset/smart-adults-suffer.md
···
···
+
---
+
'@urql/svelte': patch
+
---
+
+
Update `mutate` helper to return a Promise directly rather than a lazy Promise-like object.
+4 -15
packages/svelte-urql/src/operations/mutate.ts
···
export const mutate = <T = any, V = object>(
args: MutationArguments<V>
-
): PromiseLike<OperationResult<T>> => {
-
const client = getClient();
-
let promise: Promise<OperationResult<T>>;
-
-
return {
-
then(onValue) {
-
if (!promise) {
-
promise = client
-
.mutation(args.query, args.variables as any, args.context)
-
.toPromise();
-
}
-
-
return promise.then(onValue);
-
},
-
};
};
···
export const mutate = <T = any, V = object>(
args: MutationArguments<V>
+
): Promise<OperationResult<T>> => {
+
return getClient()
+
.mutation(args.query, args.variables as any, args.context)
+
.toPromise();
};