-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
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? 🤔
Metadata
Metadata
Assignees
Labels
No labels