data () {
return {
me: {
name: null
}
}
},
apollo: {
me: gql`{
me {
name
}
}`
}
name remains null after the query. I can access the data but only with $data.$apolloData.data.me.name which seems like the wrong way.
If I remove the me {} property from data() then I get the following error:
TypeError: Cannot read property 'hasOwnProperty' of undefined
at _loop (vue-apollo.esm.js?ebd5:3924)
at VueComponent.launch (vue-apollo.esm.js?ebd5:3938)
at callHook (vue.runtime.esm.js?ff9b:2917)
at VueComponent.Vue._init (vue.runtime.esm.js?ff9b:4626)
at new VueComponent (vue.runtime.esm.js?ff9b:4794)
at createComponentInstanceForVnode (vue.runtime.esm.js?ff9b:4306)
at init (vue.runtime.esm.js?ff9b:4127)
at createComponent (vue.runtime.esm.js?ff9b:5604)
at createElm (vue.runtime.esm.js?ff9b:5551)
at VueComponent.patch [as __patch__] (vue.runtime.esm.js?ff9b:6087)
I just started this project with vue-cli 3 and added apollo with vue-cli.
I've disabled subscriptions.
This seems to be a regression of the latest version. Will fix it tomorrow. In the meantime, you can remove your data () { ... } option.
Is there a short-term workaround for this issue?
@maziarz
It seems like a simple work around, until the issue is fixed, is to employ the result callback and set your data manually.
export default {
data () {
return {
me: {
name: null
}
}
},
apollo: {
me: {
query: gql`{
me {
name
}
}`,
result({ data, loading, networkStatus }) {
this.me = data.me
},
error(err) {
// handle your error
}
}
}
}
At least, that's what I did, and it seems to be working so far.
Hope it helps,
~ Ayiga
Thanks @Ayiga, that did the trick :-)
Same issue here, @Akryum can you fix that?
I don't think it's the correct way to use result to pass data in the vm but it's a good way before the fix. Maybe is better to downgrade to beta 5.
Maybe is better to downgrade to beta 5.
This. 馃悎
Using for the first time (through nuxtjs/apollo) been trying to figure it out all day until i came across this.
Downgrading has fixed the issue for now.
@binzcodes same here, as soon as there is a release, the nuxt module should be updated
beta 10 is released already 馃悎
@Akryum excellent! Thanks 馃
great thanks @Akryum 馃憤
Most helpful comment
This. 馃悎