Akryum / Akryum/vue-cli-plugin-apollo
How to integrate with Vuex
- Ngôn ngữ chính
- JavaScript
- Star
- 477
- Fork
- 109
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
I'm currently trying to fire off a graphQL query from inside Vuex using the apollo plugin. My store.js file looks like this:
```javascro[t
import Vue from 'vue';
import Vuex from 'vuex';
import gql from 'graphql-tag';
import { createProvider } from './vue-apollo';
const provider = createProvider();
const { apolloClient } = provider;
Vue.use(Vuex);
export default new Vuex.Store({
state: {
},
mutations: {
},
actions: {
getPosts: () => {
apolloClient
.query({
query: gql`
query {
_id
title
imageUrl
}
`
})
.then(data => console.log(data))
.catch(err => console.error(err))
}
},
});
```
But I keep on getting erors from chrome developer tools stating that it is unable to read the query property of undefined. I know that I am possibly messing this up royally, but what should I import at the top of this file to make it work?
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á.