Akryum / Akryum/vue-apollo-example

How can I port this example for use with scaphold.io

Đang mở
#2 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Vue
Star
108
Fork
23
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I can't seem to grasp your use of client. In the example you are using a web socket client.
When I try to use vue-apollo with scaphold.io config, it fails with `$apollo.client` `undefined` and also shows `query` and `mutate` properties with TypeError since `undefined`.
What gives?

screenshot 2017-01-18 10 51 50

As you can see I experimented with trying to use localhost as ws client, then disabled on advice from @vince from scaphold.io

```js
import ApolloClient, { createNetworkInterface } from 'apollo-client'
// import { Client } from 'subscriptions-transport-ws'
// import { addGraphQLSubscriptions } from 'vue-apollo';
import config from '../config/client'

const networkInterface = createNetworkInterface({
uri: config.scapholdUrl,
transportBatching: true
})

// const wsClient = new Client('ws://localhost:3001')

// const networkInterfaceWithSubscriptions = addGraphQLSubscriptions(
// networkInterface,
// wsClient,
// )

networkInterface.use([{
applyMiddleware (req, next) {
if (!req.options.headers) {
req.options.headers = {} // Create the header object if needed.
}
if (localStorage.getItem('token')) {
req.options.headers.Authorization = `Bearer ${localStorage.getItem('token')}`
}
next()
}
}])

const client = new ApolloClient({
networkInterface // : networkInterfaceWithSubscriptions
})

// Install the vue-apollo plugin and use the apollo client
Vue.use(VueApollo, {
client
})

new Vue({
...App,
apollo: {
// Apollo specific options
}
}).$mount('#app')
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.