如何使用阿波罗 2 号从端点文件进行内省


使用

apollo 1.9.2 我习惯于使用文件作为端点对 graphql 模式进行内省(这样服务器就不需要运行了)。这里是 1.9 命令:

apollo schema:download --endpoint ./schema/def/app.graphql ./schema/lib/schema.json

然后,由于生成的 json 文件,我可以生成将在客户端和服务器代码中使用的类型:

apollo codegen:generate --queries ./schema/*.graphql --schema ./schema/lib/schema.json
现在在阿波罗

2号中,阿波罗模式:下载命令(更名为apollo service:download)仅支持URL。如果我没有该类型,服务器将无法启动。鸡和蛋的问题

我现在在文档中没有找到如何做到这一点。感谢您的帮助。

我在gitHub上得到了答案

我必须使用配置文件 apollo.config.js

以下内容
module.exports = {
  service: {
    localSchemaFile: './path/to/schema.graphql',
  },
};

然后打电话

apollo service:download -c ./path/to/apollo.config.js ./schema/lib/schema.json

最新更新