From adbf0cdc3c4eb486c17cdd4257c8e46680f9e986 Mon Sep 17 00:00:00 2001 From: Sebastien Chopin Date: Thu, 14 Sep 2017 18:24:21 +0200 Subject: [PATCH 1/2] Upgrade dependencies --- examples/vue-apollo/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/vue-apollo/package.json b/examples/vue-apollo/package.json index 907e221af3..f26ec4014c 100644 --- a/examples/vue-apollo/package.json +++ b/examples/vue-apollo/package.json @@ -1,8 +1,8 @@ { "name": "nuxt-vue-apollo", "dependencies": { - "@nuxtjs/apollo": "^2.0.0", - "nuxt": "^1.0.0-rc6" + "@nuxtjs/apollo": "^2.1.1", + "nuxt": "^1.0.0-rc9" }, "scripts": { "dev": "nuxt", From 53dc5228494e2fbe35e50a864d8af67fb014c7e3 Mon Sep 17 00:00:00 2001 From: Sebastien Chopin Date: Thu, 14 Sep 2017 18:25:34 +0200 Subject: [PATCH 2/2] add: store. & this. --- lib/app/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/app/index.js b/lib/app/index.js index b6186eae01..05cf531221 100644 --- a/lib/app/index.js +++ b/lib/app/index.js @@ -43,7 +43,11 @@ const defaultTransition = <%= async function createApp (ssrContext) { const router = createRouter() - <% if (store) { %>const store = createStore()<% } %> + <% if (store) { %> + const store = createStore() + // Add this.$router into store actions/mutations + store.$router = router + <% } %> // Create Root instance // here we inject the router and store to all child components, @@ -151,6 +155,9 @@ async function createApp (ssrContext) { if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(ctx, inject)<% }) %> }<% } %> + // Inject context + inject('ctx', ctx) + if (process.server && ssrContext && ssrContext.url) { await new Promise((resolve, reject) => { router.push(ssrContext.url, resolve, reject)