Skip to content

Commit

Permalink
Fix bug handling errors in subscribePlan execution (#2081)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Jun 4, 2024
2 parents 91e87ab + 084d80b commit 8062530
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/violet-planets-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"grafast": patch
---

Fix bug handling an error raised in subscribePlan execution that was resulting
in websocket closure.
4 changes: 2 additions & 2 deletions grafast/grafast/src/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,12 @@ function executePreemptive(
// Something major went wrong!
const errors = [
new GraphQLError(
bucketRootValue.originalError.message,
bucketRootValue.message,
operationPlan.rootOutputPlan.locationDetails.node, // node
undefined, // source
null, // positions
null, // path
bucketRootValue.originalError, // originalError
bucketRootValue, // originalError
null, // extensions
),
];
Expand Down
22 changes: 22 additions & 0 deletions postgraphile/postgraphile/graphile.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,28 @@ const preset: GraphileConfig.Preset = {
},
},
}),
makeExtendSchemaPlugin({
typeDefs: gql`
extend type Subscription {
error: Int
}
`,
plans: {
Subscription: {
error: {
subscribePlan: EXPORTABLE(
(constant, lambda) =>
function subscribePlan() {
return lambda(constant(3), () => {
throw new Error("Testing error");
});
},
[constant, lambda],
),
},
},
},
}),
// PrimaryKeyMutationsOnlyPlugin,
PersistedPlugin,
makeRuruTitlePlugin("<New title text here!>"),
Expand Down

0 comments on commit 8062530

Please sign in to comment.