Skip to content

Commit

Permalink
fix: destroy apollo after render, closes vuejs#852
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Nov 26, 2019
1 parent 8bfd003 commit e6cbaa2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/vue-apollo/src/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,20 @@ export function installMixin (Vue, vueVersion) {
beforeCreate () {
initProvider.call(this)
proxyData.call(this)
if (this.$isServer) {
// Patch render function to cleanup apollo
const render = this.$options.render
this.$options.render = (h) => {
const result = render.call(this, h)
destroy.call(this)
return result
}
}
},

serverPrefetch () {
if (this.$_apolloPromises) {
return Promise.all(this.$_apolloPromises).then(result => {
// Destroy DollarApollo after SSR promises are resolved
destroy.call(this)
return result
})
return Promise.all(this.$_apolloPromises)
}
},
} : {},
Expand Down

0 comments on commit e6cbaa2

Please sign in to comment.