Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subscriptions-transport-ws subscriptionClient: Observable<ExecutionResult<ExecutionResultDataDefault>> is not assignable to type SubscriptionForwarder #8

Open
DanielLarsenNZ opened this issue Jan 8, 2020 · 0 comments

Comments

@DanielLarsenNZ
Copy link

I love this library but I am having trouble getting the Subscription client set up. Here is my code (copied from your docs):

import Vue from 'vue'
import App from './App.vue'
import { createClient } from 'vue-gql';
import { SubscriptionClient } from 'subscriptions-transport-ws';

const subscriptionClient = new SubscriptionClient('ws://localhost:4001/graphql', {});

const client = createClient({
  url: 'http://localhost:4000/graphql',
  subscriptionForwarder: op => subscriptionClient.request(op)
});
Vue.config.productionTip = false

new Vue({
  render: h => h(App),
}).$mount('#app')

When I npm run serve this (with vue-cli) I get Typescript error:

10:3 Type '(op: Operation) => Observable<ExecutionResult<ExecutionResultDataDefault>>' is not assignable to type 'SubscriptionForwarder'.
  Type 'Observable<ExecutionResult<ExecutionResultDataDefault>>' is not assignable to type 'ObservableLike<OperationResult>'.
    Types of property 'subscribe' are incompatible.
      Type '(observer: Observer<ExecutionResult<ExecutionResultDataDefault>>) => { unsubscribe: () => void; }' is not assignable to type '(observer: ObserverLike<OperationResult>) => Unsub'.
        Types of parameters 'observer' and 'observer' are incompatible.
          Type 'ObserverLike<OperationResult>' is not assignable to type 'Observer<ExecutionResult<ExecutionResultDataDefault>>'.
            Types of property 'next' are incompatible.
              Type '(value: OperationResult) => void' is not assignable to type '(value: ExecutionResult<ExecutionResultDataDefault>) => void'.
                Types of parameters 'value' and 'value' are incompatible.
                  Type 'ExecutionResult<ExecutionResultDataDefault>' is not assignable to type 'OperationResult'.                           Property 'data' is optional in type 'ExecutionResult<ExecutionResultDataDefault>' but required in type 'OperationResult'.
     8 | const client = createClient({
     9 |   url: 'http://localhost:4000/graphql',
  > 10 |   subscriptionForwarder: op => subscriptionClient.request(op)
       |   ^
    11 | });
    12 | Vue.config.productionTip = false
    13 |
Version: typescript 3.5.3
Time: 4819ms

package.json:

{
  "name": "foobar",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build"
  },
  "dependencies": {
    "graphql": "^14.5.8",
    "subscriptions-transport-ws": "^0.9.16",
    "vue": "^2.6.10",
    "vue-gql": "^0.2.3"
  },
  "devDependencies": {
    "@vue/cli-plugin-typescript": "^4.1.0",
    "@vue/cli-service": "^4.1.0",
    "typescript": "~3.5.3",
    "vue-template-compiler": "^2.6.10"
  }
}

What am I doing wrong here? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant