From 3893e191ed31b8459fb15d782810a86d30d22456 Mon Sep 17 00:00:00 2001 From: SVogel Date: Wed, 26 Jul 2017 11:27:59 +0200 Subject: [PATCH] fixed vue apollo --- examples/vue-apollo/middleware/apollo.js | 7 ------- examples/vue-apollo/nuxt.config.js | 3 --- examples/vue-apollo/package.json | 2 +- examples/vue-apollo/plugins/apollo.js | 4 +++- 4 files changed, 4 insertions(+), 12 deletions(-) delete mode 100644 examples/vue-apollo/middleware/apollo.js diff --git a/examples/vue-apollo/middleware/apollo.js b/examples/vue-apollo/middleware/apollo.js deleted file mode 100644 index 7b079c92f1..0000000000 --- a/examples/vue-apollo/middleware/apollo.js +++ /dev/null @@ -1,7 +0,0 @@ -export default async function ({ isServer, apolloProvider }) { - if (isServer) { - const ensureReady = apolloProvider.collect() - console.log('Call ensureReady!', ensureReady()) - await ensureReady() - } -} diff --git a/examples/vue-apollo/nuxt.config.js b/examples/vue-apollo/nuxt.config.js index f73ea6eaf6..dfd7d27df7 100644 --- a/examples/vue-apollo/nuxt.config.js +++ b/examples/vue-apollo/nuxt.config.js @@ -2,9 +2,6 @@ module.exports = { build: { vendor: ['vue-apollo', 'apollo-client'] }, - router: { - middleware: 'apollo' - }, plugins: [ // Will inject the plugin in the $root app and also in the context as `apolloProvider` { src: '~plugins/apollo.js', injectAs: 'apolloProvider' } diff --git a/examples/vue-apollo/package.json b/examples/vue-apollo/package.json index 2f823a1e8e..07c1fcaf2a 100644 --- a/examples/vue-apollo/package.json +++ b/examples/vue-apollo/package.json @@ -6,7 +6,7 @@ "vue-apollo": "^2.1.0-beta.2" }, "scripts": { - "dev": "node server.js", + "dev": "nuxt", "build": "nuxt build", "start": "cross-env NODE_ENV=production node server.js" } diff --git a/examples/vue-apollo/plugins/apollo.js b/examples/vue-apollo/plugins/apollo.js index cf888008c9..e59acd3369 100644 --- a/examples/vue-apollo/plugins/apollo.js +++ b/examples/vue-apollo/plugins/apollo.js @@ -3,7 +3,6 @@ import Vue from 'vue' import VueApollo from 'vue-apollo' import { ApolloClient, createNetworkInterface } from 'apollo-client' -Vue.use(VueApollo) const API_ENDPOINT = 'https://api.graph.cool/simple/v1/cj1dqiyvqqnmj0113yuqamkuu' @@ -18,4 +17,7 @@ const apolloProvider = new VueApollo({ defaultClient: apolloClient }) +Vue.use(VueApollo) +Vue.mixin({apolloProvider}) + export default apolloProvider