apollographql / graphql-subscriptions

:newspaper: A small module that implements GraphQL subscriptions for Node.js
MIT License
1.59k stars 133 forks source link

Subscribe returns a Promise<number>, but sometimes we want to cancel a subscription #177

Open grantwwu opened 5 years ago

grantwwu commented 5 years ago

I guess this is related to promise cancellation..?

https://github.com/apollographql/graphql-subscriptions/blob/master/src/pubsub-engine.ts#L3

subscribe(triggerName: string, onMessage: Function, options: Object): Promise<number>

is problematic because we may want the connection ID (I assume that's what the number is for?) before we connect, in order to say, close it.

grantwwu commented 5 years ago

Additionally, sometimes we want to be able to cancel a subscription before a Promise returns.