Skip to content

Commit 40adebf

Browse files
committed
subscribe: once execution starts....
data should return null?
1 parent e24f426 commit 40adebf

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/execution/__tests__/subscribe-test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ describe('Subscription Initialization Phase', () => {
427427

428428
const result = subscribe({ schema, document });
429429
expectJSON(result).toDeepEqual({
430+
data: null,
430431
errors: [
431432
{
432433
message:
@@ -451,6 +452,7 @@ describe('Subscription Initialization Phase', () => {
451452

452453
const result = subscribe({ schema, document });
453454
expectJSON(result).toDeepEqual({
455+
data: null,
454456
errors: [
455457
{
456458
message: 'The subscription field "unknownField" is not defined.',
@@ -477,6 +479,7 @@ describe('Subscription Initialization Phase', () => {
477479

478480
it('throws an error if subscribe does not return an iterator', async () => {
479481
const expectedResult = {
482+
data: null,
480483
errors: [
481484
{
482485
message:
@@ -498,6 +501,7 @@ describe('Subscription Initialization Phase', () => {
498501

499502
it('resolves to an error for subscription resolver errors', async () => {
500503
const expectedResult = {
504+
data: null,
501505
errors: [
502506
{
503507
message: 'test error',

src/execution/execute.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,12 +1141,15 @@ export function createSourceEventStream(
11411141
try {
11421142
const eventStream = executeSubscription(exeContext);
11431143
if (isPromise(eventStream)) {
1144-
return eventStream.then(undefined, (error) => ({ errors: [error] }));
1144+
return eventStream.then(undefined, (error) => ({
1145+
data: null,
1146+
errors: [error],
1147+
}));
11451148
}
11461149

11471150
return eventStream;
11481151
} catch (error) {
1149-
return { errors: [error] };
1152+
return { data: null, errors: [error] };
11501153
}
11511154
}
11521155

0 commit comments

Comments
 (0)