Akryum / Akryum/vue-cli-plugin-apollo
How to integrate with Vuex
- Dominant language
- JavaScript
- Stars
- 477
- Forks
- 109
- PR merge metrics
- No merged PRs in 30d
Description
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?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.