Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug handling errors in subscribePlan execution #2081

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading