继续获取未定义的查询...谁能告诉我如何使用Nuxtjs访问Vuex商店中的this.$apollo.query?
import gqlGetAllTags from '~/apollo/queries/gqlGetAllTags.gql'
@Module({
stateFactory: true,
namespaced: true,
name: 'products',
})
export default class Products extends VuexModule {
product: Array<object> = []
@Mutation
GET_PRODUCT(product: Array<object>) {
this.product = product
}
@Action({ rawError: true })
async getProduct() {
const collection = await this.$apollo.query({
query: gqlGetAllTags,
variables: {
handle: 'nirvana',
},
})
this.context.commit('GET_PRODUCT', collection)
}
}
发布于 2020-11-01 10:38:40
您可以在Vuex操作中使用Appolo提供程序,如下所示。
const collection = await this.app.apolloProvider.clients.defaultClient
.query({
query: gqlGetAllTags,
variables: {
handle: 'nirvana',
},
})
https://stackoverflow.com/questions/64598978
复制相似问题