apollo
apollo copied to clipboard
fix: do not manually call provide
Context
Over at GitLab, we ran into a weird quirk with VueApollo (see relevant GitLab comment).
Here's a sandbox example of the issue we ran into:
// 1) Somewhere we use VueApollo
Vue.use(VueApollo);
// 2) Elsewhere, we initialize a top-level Vue app that **does not** give `apolloProvider`
import Root from './root.vue';
new Vue({
el,
render(h) {
return h(Root, {
props: {
username: 'sam'
}
};
},
})
// root.vue
export default {
provide() {
// 3) This blows up because VueApollo manually calls `provide` on `beforeCreate`.
// Vue will usually call this **after** props and things have been set up.
return {
username: this.username
};
},
props: {
username: {
type: String,
required: true,
},
},
}
It looks like this manual calling of options.provide was to support an old VueApollo API, but since Vue 2.2.0,
Vue automatically supports provide. I'm guessing this isn't needed anymore :shrug:
@Akryum could you review this small PR that removes some code tagged TODO remove? Thank you! :bow:
Hi @Akryum, any update on this? Could it be merged? 🙂
I just came across another case in a GitLab vue component where this causes an issue.