-
-
Notifications
You must be signed in to change notification settings - Fork 522
Closed
Labels
Description
Describe the bug
Multiple web-components on a page implementing vue-apollo 3.0.3. lead to re-definition error of $apollo
To Reproduce
Steps to reproduce the behavior:
- Build 2 vue components seperatly that both implement vue-apollo using whatever your bundler is. We're using https://cli.vuejs.org/guide/cli-service.html#vue-cli-service-build Vue-Cli-Service
- Import both of these web-components into a new page
- See error
Uncaught TypeError: Cannot redefine property: $apollo
Expected behavior
- This error would not occur
- vue-apollo would check if it's redefining $apollo
- In
packages>vue-apollo>src>index.js
the Apollo package would wrap define in a check to see if $apollo is already defined.
// Lazy creation
if (!Vue.prototype.hasOwnProperty('$apollo')) {
Object.defineProperty(Vue.prototype, '$apollo', {
get () {
if (!this.$_apollo) {
this.$_apollo = new DollarApollo(this)
}
return this.$_apollo
},
})
}
Versions
vue: "^2.6.11"
vue-apollo: 3.0.3
apollo-client: "^2.6.4"
Additional context
Seems that this was a past issue, and had been resolved, and then removed?
#358
66b8cc9#diff-6c29e3b5395a867dff4aa2f0dc7124b2
I would have added a PR, but could not figure out how to build dist files.
JoshuaJarman