-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
waiting-for-answerWaiting for answer from authorWaiting for answer from author
Description
The latest version of graphql-code-generator has changed the subscribe function return type to AsyncIterable<TResult> | Promise<AsyncIterable<TResult>>;
However, when using apollo's graphql-subscriptions lib, the type returned from their pubsub-engine is AsyncIterator https://github.com/apollographql/graphql-subscriptions/blob/master/src/pubsub-engine.ts#L8
AsyncIterable and AsyncIterator types are incompatible.
Example (this code will throw a type error):
const pubsub = new PubSub();
const typeDefs = gql`
type Subscription {
root: String
}
`
const resolvers: Resolvers = {
Subscription: {
root: {
subscribe: () => {
// Type 'AsyncIterator<unknown, any, undefined>' is not assignable to type 'AsyncIterable<any> | Promise<AsyncIterable<any>>'.
return pubsub.asyncIterator('root');
}
}
}
};
What's the recommended workaround for this issue?
rustic0la, maxrchung, maxpain, hckr, mikecann and 18 more
Metadata
Metadata
Assignees
Labels
waiting-for-answerWaiting for answer from authorWaiting for answer from author