-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
I noticed that the subscribe function does not work properly when it is used with an asynchronous field resolver function.
Also, there is no unit test for this case. This is what I have in mind (must be added to subscribe-test.js):
it('should work with an asynchronous resolver', async () => {
const asyncEmailSchema = emailSchemaWithResolvers(
async function*() {
yield { email: { subject: 'Hello' } };
},
async function*(email) { // <-- this currently does not work
return email;
},
);
const subscription = await subscribe(
asyncEmailSchema,
parse(`
subscription {
importantEmail {
email {
subject
}
}
}
`),
);
const payload = await subscription.next();
expect(payload).to.deep.equal({
done: false,
value: {
data: {
importantEmail: {
email: {
subject: 'Hello',
},
},
},
},
});
expect(await subscription.next()).to.deep.equal({
done: true,
value: undefined,
});
});Is this an oversight? Or am I doing something stupid or against the spec? As far as I see the ResolveFieldEventStream section says nothing about whether the resolver function can be asynchronous, so I am assuming that is allowed, just at it is for resolver function used for normal queries, and as far as I understand it is intended that they are compatible.
Metadata
Metadata
Assignees
Labels
No labels