從graphql endpoint獲取schema文件


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

 You can get schema like this.

 

 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.

At last,  we  get the  damn schema.json by graphql get-schema --output="schema.json"

 

 Done. 

Happy Mid-Autumn Festival !

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM