logaretm / villus

🏎 A tiny and fast GraphQL client for Vue.js

Home Page:https://villus.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typings Error when using graphql-ws

sasial-dev opened this issue · comments

When using the graphql-ws example in the docs from the subscriptions page, I get the follow typings issue:

Argument of type '(operation: any) => { subscribe: (obs: any) => void; }' is not assignable to parameter of type 'SubscriptionForwarder<any>'.
  Call signature return types '{ subscribe: (obs: any) => void; }' and 'ObservableLike<StandardOperationResult<any>>' are incompatible.
    The types returned by 'subscribe(...)' are incompatible between these types.
      Type 'void' is not assignable to type 'Unsubscribable'.

Any idea how to solve this? Since subscriptions-transport-ws is no longer maintained it's recommended to use graphql-ws instead.

Dirty solution for the typescript issue, just return an object at the end of subscribe like this:

{
    unsubscribe: () => console.warn('unsubscribed')
}

But I would be happy for better solutions

similar issue as in #186 I made some changes to the internal ObserverLike interface to make it compatible since this is the lib recommended now.

I also updated the docs. Should be addressed in the next patch 2.1.1