我正在使用Nuxt和Nuxt-Apollo创建我的Vue应用程序。我在nuxt.config.js
文件中有以下apollo配置:
apollo: {
clientConfigs: {
default: {
httpEndpoint: 'http://localhost:8000/graphql/'
},
stage: {
httpEndpoint: 'https://example-stage.com/graphql/'
}
prod: {
httpEndpoint: 'https://example.com/graphql/'
}
}
}
字符串
如何指向stage
或prod
配置。每次我运行应用程序时,它都指向default
配置。一定有地方可以设置的。
2条答案
按热度按时间lztngnrs1#
假设你正在尝试访问多个客户端,而不仅仅是一个不同的客户端的prod和dev,这可能会有所帮助,因为这是我用我目前的项目。
字符串
现在你需要做的就是让你的查询正常,但不同的是在vue组件。
/gql/allCars.gql
型
调用default将像正常情况一样进行:
型
对辅助端点的调用需要添加$client:
型
apollo调试器似乎只查询apollo config中端点列表上的最后一个端点,在我的例子中是'otherClient',这一点毫无价值。
参考我是如何得出上述集成的:Vue multiple client
nbysray52#
如果您使用的是Pinia和Nuxt 3,您可以使用$apollo来选择所需的客户端:
假设“prod”客户端:
字符串
假设你已经设置了模块:'@nuxtjs/apollo'