【问题标题】:Apollo Client Full WebSocket Transport gives me the error this.networkInterface.query is not a functionApollo Client Full WebSocket Transport 给了我错误 this.networkInterface.query is not a function
【发布时间】:2018-03-19 03:13:18
【问题描述】:

我可以使混合方法起作用,但我想使用完整的 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>

【问题讨论】:

    标签: javascript apollo apollo-client


    【解决方案1】:

    subscriptions-transport-ws 在 0.9.x 版本中有一些重大更改。您可以安装 0.8.3 或尝试使较新的版本工作。

    【讨论】:

      猜你喜欢
      • 2020-11-29
      • 2020-05-11
      • 2020-12-11
      • 1970-01-01
      • 2019-09-07
      • 2022-08-03
      • 2020-04-24
      • 1970-01-01
      • 2018-05-02
      相关资源
      最近更新 更多