Skip to content

Commit 46ea781

Browse files
committed
fix(ssr): mock $apollo after serverPrefetch, fix #1297
1 parent fa74bbb commit 46ea781

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/vue-apollo-option/src/mixin.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,16 @@ export function installMixin (app, provider) {
126126
serverPrefetch () {
127127
if (this.$_apolloPromises) {
128128
return Promise.all(this.$_apolloPromises).then(() => {
129+
// Mock `$apollo` for the render function
130+
const mocked = {
131+
vm: this,
132+
provider: this.$apollo.provider,
133+
loading: false,
134+
queries: {},
135+
subscriptions: {},
136+
}
129137
destroy.call(this)
138+
this.$apollo = mocked
130139
}).catch(e => {
131140
destroy.call(this)
132141
return Promise.reject(e)

0 commit comments

Comments
 (0)