Skip to content

Commit

Permalink
make MutationStore.mutation return full payload
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecAivazis committed Feb 1, 2023
1 parent 4a215be commit 48ad145
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
</form>

<div id="result">
{form?.addUser?.name || 'No user added'}
{form?.data?.addUser?.name || 'No user added'}
</div>
24 changes: 11 additions & 13 deletions packages/houdini-svelte/src/runtime/stores/mutation.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -26,7 +26,7 @@ export class MutationStore<
fetch?: typeof globalThis.fetch
event?: RequestEvent
} & MutationConfig<_Data, _Input, _Optimistic> = {}
): Promise<_Data> {
): Promise<QueryResult<_Data, _Input>> {
await initClient()

const { context } = await fetchParams(this.artifact, this.artifact.name, {
Expand All @@ -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<DocumentStore<_Data, _Input>['subscribe']>) {
Expand Down

0 comments on commit 48ad145

Please sign in to comment.