diff --git a/.changeset/cool-panthers-juggle.md b/.changeset/cool-panthers-juggle.md new file mode 100644 index 000000000..b861a29d3 --- /dev/null +++ b/.changeset/cool-panthers-juggle.md @@ -0,0 +1,5 @@ +--- +'houdini-svelte': major +--- + +MutationStore.mutate returns full payload diff --git a/e2e/sveltekit/src/routes/stores/action-mutation/+page.svelte b/e2e/sveltekit/src/routes/stores/action-mutation/+page.svelte index 947358282..25f96781d 100644 --- a/e2e/sveltekit/src/routes/stores/action-mutation/+page.svelte +++ b/e2e/sveltekit/src/routes/stores/action-mutation/+page.svelte @@ -17,5 +17,5 @@
- {form?.addUser?.name || 'No user added'} + {form?.data?.addUser?.name || 'No user added'}
diff --git a/packages/houdini-svelte/src/runtime/stores/mutation.ts b/packages/houdini-svelte/src/runtime/stores/mutation.ts index 542e28227..f5831eb1b 100644 --- a/packages/houdini-svelte/src/runtime/stores/mutation.ts +++ b/packages/houdini-svelte/src/runtime/stores/mutation.ts @@ -1,5 +1,5 @@ import type { DocumentStore } from '$houdini/runtime/client' -import type { MutationArtifact, GraphQLObject } from '$houdini/runtime/lib/types' +import type { MutationArtifact, GraphQLObject, QueryResult } from '$houdini/runtime/lib/types' import type { RequestEvent } from '@sveltejs/kit' import { initClient } from '../client' @@ -26,7 +26,7 @@ export class MutationStore< fetch?: typeof globalThis.fetch event?: RequestEvent } & MutationConfig<_Data, _Input, _Optimistic> = {} - ): Promise<_Data> { + ): Promise> { await initClient() const { context } = await fetchParams(this.artifact, this.artifact.name, { @@ -35,17 +35,15 @@ export class MutationStore< event, }) - return ( - await this.observer.send({ - variables, - fetch: context.fetch, - metadata, - session: context.session, - stuff: { - ...mutationConfig, - }, - }) - ).data! + return await this.observer.send({ + variables, + fetch: context.fetch, + metadata, + session: context.session, + stuff: { + ...mutationConfig, + }, + }) } subscribe(...args: Parameters['subscribe']>) { diff --git a/site/src/routes/guides/release-notes/+page.svx b/site/src/routes/guides/release-notes/+page.svx index 607e54f9c..89ebfbfd3 100644 --- a/site/src/routes/guides/release-notes/+page.svx +++ b/site/src/routes/guides/release-notes/+page.svx @@ -206,6 +206,29 @@ need to pass a new config to your client: +### Mutation return value changed + +Because of the change in Houdini's default error handling, mutations were brought +in line with query behavior and return the full query result with `data`, `errors`, +etc. + +```diff:title=src/components/AddFriend.svelte + +``` + ### Grouped `apiUrl`, `schemaPollHeaders`, and `schemaPollInterval` together In order to clarify the difference between the `apiUrl` config value and the