【发布时间】:2019-12-16 14:34:17
【问题描述】:
我在 Nuxt 应用程序中使用 Apollo。我正在尝试在一种方法中使用我的非默认客户端(Shopify)。理想情况下是这样的:
在我的nuxt.config.js 中,我有这样的 Apollo 设置:
apollo: {
clientConfigs: {
default: {
httpEndpoint:
"http://example.com",
tokenName: "apollo-token",
persisting: false,
websocketsOnly: false
},
shopify: {
httpEndpoint:
"http://example.shopify.com",
tokenName: "apollo-token"
... etc...
}
}
}
然后在我的组件中,我有这个方法:
methods: {
createCheckout() {
this.$apollo.getClient("shopify")
.mutate({
mutation: this.checkoutQuery,
variables: {
variantId: this.selectedProduct.variantId,
quantity: this.selectedProduct.quantity
}
})
}
}}
这不起作用,因为getClient() 只返回默认客户端(在本例中为 WordPress)。那么如何在方法中访问其他客户端呢?
【问题讨论】:
标签: javascript vue.js shopify nuxt.js apollo