Closed JarvisH closed 3 years ago
There is no way villus can support all types of subscription clients, so you need to follow the interfaces defined by villus.
Villus expects the subscribe method to return an "Unsubscribe" object, so you need to return it manually.
As for the query type, you can use graphql
to convert it to a string, I haven't decided yet if villus
should do that or not because it has no control over the transport layer for subscriptions unlike queries/mutations.
Again
import { print } from 'graphql';
const subscriptionForwarder: SubscriptionForwarder = operation => {
return {
subscribe: obs => {
wsClient.subscribe(
{
query: typeof operation.query === 'string' ? operation.query : print(operation.query),
},
obs
);
return {
unsubscribe: () => wsClient.dispose(),
}
},
};
};
First up, thanks for fixing all other reported issues so quickly!
According to the documentation it should be possible to use
graphql-ws
as a websocket client for subscriptions.Using the below example in a typescript project shows the followin TS errors:
Error 1:
... and error 2:
Am I doing something wrong here?