2017-10-07 210 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或嘗試使新版本工作。