Skip to content

Commit 2afbf0b

Browse files
Fix build after #1467 (#2014)
1 parent d4a1362 commit 2afbf0b

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

src/subscription/__tests__/subscribe-test.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,9 @@ describe('Subscription Initialization Phase', () => {
434434

435435
it('resolves to an error for source event stream resolver errors', async () => {
436436
// Returning an error
437-
const subscriptionReturningErrorSchema = emailSchemaWithResolvers(() => {
438-
return new Error('test error');
439-
});
437+
const subscriptionReturningErrorSchema = emailSchemaWithResolvers(
438+
() => new Error('test error'),
439+
);
440440
await testReportsError(subscriptionReturningErrorSchema);
441441

442442
// Throwing an error
@@ -446,10 +446,8 @@ describe('Subscription Initialization Phase', () => {
446446
await testReportsError(subscriptionThrowingErrorSchema);
447447

448448
// Resolving to an error
449-
const subscriptionResolvingErrorSchema = emailSchemaWithResolvers(
450-
async () => {
451-
return new Error('test error');
452-
},
449+
const subscriptionResolvingErrorSchema = emailSchemaWithResolvers(() =>
450+
Promise.resolve(new Error('test error')),
453451
);
454452
await testReportsError(subscriptionResolvingErrorSchema);
455453

@@ -1013,6 +1011,7 @@ describe('Subscription Publish Phase', () => {
10131011
`),
10141012
);
10151013

1014+
// $FlowFixMe
10161015
const payload1 = await subscription.next();
10171016
expect(payload1).to.deep.equal({
10181017
done: false,

src/subscription/subscribe.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,15 @@ function subscribeImpl(
151151

152152
// Resolve the Source Stream, then map every source value to a
153153
// ExecutionResult value as described above.
154-
return sourcePromise.then(
155-
resultOrStream =>
156-
// Note: Flow can't refine isAsyncIterable, so explicit casts are used.
157-
isAsyncIterable(resultOrStream)
158-
? mapAsyncIterator(
159-
((resultOrStream: any): AsyncIterable<mixed>),
160-
mapSourceToResponse,
161-
reportGraphQLError,
162-
)
163-
: ((resultOrStream: any): ExecutionResult),
154+
return sourcePromise.then(resultOrStream =>
155+
// Note: Flow can't refine isAsyncIterable, so explicit casts are used.
156+
isAsyncIterable(resultOrStream)
157+
? mapAsyncIterator(
158+
((resultOrStream: any): AsyncIterable<mixed>),
159+
mapSourceToResponse,
160+
reportGraphQLError,
161+
)
162+
: ((resultOrStream: any): ExecutionResult),
164163
);
165164
}
166165

0 commit comments

Comments
 (0)