From 768e4688b98c1f517b44637d636d0babfe4d64cc Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Thu, 30 Aug 2018 13:36:15 +0200 Subject: [PATCH] refactor: SSR --- docs/.vuepress/config.js | 1 + docs/api/apollo-provider.md | 98 ---------- docs/api/ssr.md | 55 ++++++ docs/guide/ssr.md | 107 ++++++----- {src => lib}/consts.js | 2 +- {src => lib}/utils.js | 18 +- package.json | 3 +- src/apollo-provider.js | 177 ------------------ src/components/ApolloMutation.js | 2 +- src/dollar-apollo.js | 2 +- src/index.js | 3 +- src/mixin.js | 2 +- src/smart-apollo.js | 2 +- src/smart-query.js | 2 +- ssr/consts.js | 29 +++ ssr/index.js | 305 +++++++++++++++++++++++++++++++ 16 files changed, 473 insertions(+), 335 deletions(-) create mode 100644 docs/api/ssr.md rename {src => lib}/consts.js (80%) rename {src => lib}/utils.js (57%) create mode 100644 ssr/consts.js create mode 100644 ssr/index.js diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 0c20dfe..75476de 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -76,6 +76,7 @@ module.exports = { children: [ 'apollo-provider', 'dollar-apollo', + 'ssr', ] }, { diff --git a/docs/api/apollo-provider.md b/docs/api/apollo-provider.md index 09e7e81..770a8c9 100644 --- a/docs/api/apollo-provider.md +++ b/docs/api/apollo-provider.md @@ -45,101 +45,3 @@ new Vue({ render: h => h(App), }) ``` - -## Methods - -### provide - -Use this to inject the provider into an app: - -```js -new Vue({ - el: '#app', - provide: apolloProvider.provide(), - render: h => h(App), -}) -``` - -### prefetchAll - -(SSR) Prefetch all queued component definitions and returns a promise resolved when all corresponding apollo data is ready. - -```js -await apolloProvider.prefetchAll (context, componentDefs, options) -``` - -`context` is passed as the argument to the `prefetch` options inside the smart queries. It may contain the route and the store. - -`options` defaults to: - -```js -{ - // Include components outside of the routes - // that are registered with `willPrefetch` - includeGlobal: true, -} -``` - -### getStates - -(SSR) Returns the apollo stores states as JavaScript objects. - -```js -const states = apolloProvider.getStates(options) -``` - -`options` defaults to: - -```js -{ - // Prefix for the keys of each apollo client state - exportNamespace: '', -} -``` - -### exportStates - -(SSR) Returns the apollo stores states as JavaScript code inside a String. This code can be directly injected to the page HTML inside a `