Skip to content

Commit

Permalink
fix: revert subscription event source stream handling (#5965)
Browse files Browse the repository at this point in the history
* fix: revert subscription event source stream handling

* fix: wrap error

* test: ensure location is there

* better assertion condition
  • Loading branch information
n1ru4l authored Mar 11, 2024
1 parent baf3c28 commit 3e10da6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-ways-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphql-tools/executor": patch
---

revert subscription event source error handling to graphql-js behaviour
15 changes: 3 additions & 12 deletions packages/executor/src/execution/__tests__/subscribe-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1287,18 +1287,9 @@ describe('Subscription Publish Phase', () => {
},
});

const resultThree = await iterator.next();

expect(JSON.parse(JSON.stringify(resultThree))).toEqual({
done: false,
value: {
errors: [
{
message: 'test error',
locations: [{ line: 2, column: 9 }],
},
],
},
await expect(iterator.next()).rejects.toMatchObject({
message: 'test error',
locations: [{ line: 2, column: 9 }],
});

const endResult = await iterator.next();
Expand Down
6 changes: 2 additions & 4 deletions packages/executor/src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1631,14 +1631,12 @@ function mapSourceToResponse(
await executeImpl(buildPerEventExecutionContext(exeContext, payload)),
exeContext.signal,
),
async function* (error: Error) {
(error: Error) => {
const wrappedError = createGraphQLError(error.message, {
originalError: error,
nodes: [exeContext.operation],
});
yield {
errors: [wrappedError],
};
throw wrappedError;
},
),
);
Expand Down

0 comments on commit 3e10da6

Please sign in to comment.