Akryum / Akryum/vue-cli-plugin-apollo

How to integrate with Vuex

オープン
#66 コメント 9 件 リアクション 2 件 担当者 0 名 GitHub で見る
question
主要言語
JavaScript
スター
477
フォーク
109
PR マージ指標
30日以内にマージされた PR はありません

説明

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?

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。