Apollo Client Full WebSocket Transport给出了错误this.networkInterface.query不是函数

时间:2017-10-07 13:12:30

标签: javascript apollo apollo-client

我可以使混合方法工作,但我想使用完整的websocket传输,其中每个graphql操作都通过套接字完成。我确实喜欢他们的documentation

import { SubscriptionClient } from 'subscriptions-transport-ws'
import ApolloClient from 'apollo-client'
import gql from 'graphql-tag'

const client = new SubscriptionClient('ws://localhost:5000/graphql', { reconnect: true })
const apolloClient = new ApolloClient({ networkInterface: client })

apolloClient.query({
  query: gql`query { app }`
})

给我错误:

Uncaught (in promise) Error: Network error: this.networkInterface.query is not a function
    at new ApolloError (ApolloError.js:34)
    at QueryManager.js:325
    at QueryManager.js:818
    at Array.forEach (<anonymous>)
    at QueryManager.js:815
    at Array.forEach (<anonymous>)
    at QueryManager.broadcastQueries (QueryManager.js:812)
    at QueryManager.js:281
    at <anonymous>

1 个答案:

答案 0 :(得分:0)

subscriptions-transport-ws在0.9.x版本中有一些重大变化。您可以安装0.8.3或尝试使新版本正常工作。