2017-10-07 29 views
0

我可以使混合方法工作,但我想使用完整的websocket传输,其中每个graphql操作都通过套接字完成。我的确和他们的documentation一样。Apollo客户端完整的WebSocket传输给我错误this.networkInterface.query不是函数

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> 

回答

0

订阅运输-WS在0.9.x版本的版本有一些重大的变化。您可以安装0.8.3或尝试使新版本工作。