Skip to content

Commit

Permalink
Update example and minor type tweaks (#569)
Browse files Browse the repository at this point in the history
* 🐛 DOC: mutation (#560)

* 🐛 DOC: mutation

* 🚸 DOC: making it more clear

* mutation result never null

* subscription listen is optional

* added changesets

* fix build errors

Co-authored-by: JYC <[email protected]>
  • Loading branch information
AlecAivazis and jycouet authored Sep 25, 2022
1 parent ad0ed5b commit 08f834a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/large-forks-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'houdini': patch
---

Mutation result is never null
5 changes: 5 additions & 0 deletions .changeset/sour-students-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'houdini': patch
---

Subscription.listen arguments are optional
4 changes: 2 additions & 2 deletions src/runtime/stores/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class MutationStore<
metadata?: App.Metadata
fetch?: typeof globalThis.fetch
} & MutationConfig<_Data, _Input, _Optimistic> = {}
): Promise<_Data | null> {
): Promise<_Data> {
const config = await this.getConfig()

this.store.update((c) => {
Expand Down Expand Up @@ -132,7 +132,7 @@ export class MutationStore<
this.store.set(storeData)

// return the value to the caller
return storeData.data
return storeData.data ?? ({} as _Data)
} catch (error) {
this.store.update((s) => ({
...s,
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/stores/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ export class SubscriptionStore<_Data, _Input extends {}> extends BaseStore {
return this.store?.subscribe(...args)
}

async listen(variables: _Input) {
async listen(variables?: _Input) {
// @ts-expect-error: typechecking cjs/esm interop is hard
// pull the query text out of the compiled artifact
const { raw: text, selection } = artifact.default || artifact
const { raw: text, selection } = this.artifact.default || this.artifact

// subscription.listen is a no-op on the server
if (!isBrowser) {
Expand Down

2 comments on commit 08f834a

@vercel
Copy link

@vercel vercel bot commented on 08f834a Sep 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs-next – ./site

docs-next-houdinigraphql.vercel.app
docs-next-git-main-houdinigraphql.vercel.app
docs-next-kohl.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 08f834a Sep 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.