Skip to content

Commit e612138

Browse files
committed
fix vue-apollo setup
1 parent 094d678 commit e612138

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

client_source/components/Hello.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<button @click="decrement">-</button>
55
<button @click="increment">+</button>
66
<h1>GraphQL</h1>
7-
<textarea>{{result}}</textarea>
7+
<textarea>{{users}}</textarea>
88
</div>
99
</template>
1010

@@ -19,11 +19,11 @@ export default Vue.extend({
1919
data() {
2020
return {
2121
enthusiasm: this.initialEnthusiasm,
22-
result: '',
22+
users: '',
2323
};
2424
},
2525
apollo: {
26-
result: {
26+
users: {
2727
query: AllUsers
2828
}
2929
},

client_source/graphql/AllUsers.gql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
query users {
2-
name
1+
query {
2+
users {
3+
name
4+
}
35
}

client_source/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ const apolloClient = new ApolloClient({
1818
connectToDevTools: process.env.NODE_ENV !== 'production',
1919
});
2020

21-
Vue.use(VueApollo, {
22-
apolloClient,
21+
const apolloProvider = new VueApollo({
22+
defaultClient: apolloClient,
2323
});
2424

25+
Vue.use(VueApollo);
26+
2527
let app = new Vue({
2628
el: '#app',
2729
template: `
@@ -37,6 +39,7 @@ let app = new Vue({
3739
</div>
3840
`,
3941
data: { name: 'World', visible: false },
42+
provide: apolloProvider.provide(),
4043
components: {
4144
HelloComponent,
4245
elButton: Button,

0 commit comments

Comments
 (0)