从graphql endpoint获取schema文件

本文介绍了一种通过graphql-cli工具从GraphQL server端获取最新schema的方法,包括安装graphql-cli、配置特定header并最终导出schema.json文件的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

graphql server端有更新,client端需要重新获取schema文件用于创建新的api request,下面简要记录如何从graphql endpoint获取schema文件

 You can simply install the CLI using npm or yarn by running the following command. This will add the graphql (and shorter gql) binary to your path.

    npm install -g graphql-cli

 Then, you can type [command] just like bellow to create  a  file named  .graphqlconfig

 

 

 Now , you can get schema 

 

 Ops! Now specific headers is needed. We open .graphqlconfig file to edit it.

 

 Pay attention to edit this file, since it's very important to the result.

OK, now we can get the  damn schema.json by 

 graphql get-schema --output="schema.json"

 

 Done. Now I can go to bed and have a good sleep.

Happy Mid-Autumn Festival !

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值