Closed JarvisH closed 1 year ago
When using graphql-ws like so:
import { createClient } from 'graphql-ws' const wsClient = createClient(...) ... use: [ handleSubscriptions(operation => { return { subscribe: obs => { wsClient.subscribe( { query: ..., variables: ... }, obs ) return { unsubscribe: () => {} } } } }),
The following Typescript error occurs for the obs argument:
obs
Argument of type 'ObserverLike<StandardOperationResult<any>>' is not assignable to parameter of type 'Sink<ExecutionResult<any, ObjMap<unknown>>>'
It essentially boils down to this Villus interface:
interface ObserverLike<T> { next?: (value: T) => void; error?: (err: any) => void; complete?: () => void; }
vs. this grapqhl-ws interface:
interface Sink<T = unknown> { next(value: T): void; error(error: unknown): void; complete(): void; }
I can understand the difficulty of ensuring compatibility with all sorts of external libraries, on the other hand, if the properties in interface ObserverLike do not have to be optional it would be an easy fix.
interface ObserverLike
That makes sense. Even if someone are using some other implementation they could just provide a no op functions.
no op
When using graphql-ws like so:
The following Typescript error occurs for the
obs
argument:It essentially boils down to this Villus interface:
vs. this grapqhl-ws interface:
I can understand the difficulty of ensuring compatibility with all sorts of external libraries, on the other hand, if the properties in
interface ObserverLike
do not have to be optional it would be an easy fix.