简体   繁体   English

如何使用 Python 获取 GraphQL 架构?

[英]How to get GraphQL schema with Python?

There's lots of GUI clients like GraphQL Playground, GraphiQl, etc. with ability of getting GraphQL schema from the URL.有许多 GUI 客户端,如 GraphQL Playground、GraphiQl 等,它们能够从 URL 获取 GraphQL 模式。 How can I get the schema with Python?如何使用 Python 获取架构?

There's lots of GUI clients like GraphQL Playground, GraphiQl, etc. with ability of getting GraphQL schema from the URL.有很多 GUI 客户端,如 GraphQL Playground、GraphiQl 等,能够从 URL 获取 GraphQL 模式。 How can I get the schema with Python?如何使用 Python 获取模式?

There's lots of GUI clients like GraphQL Playground, GraphiQl, etc. with ability of getting GraphQL schema from the URL.有很多 GUI 客户端,如 GraphQL Playground、GraphiQl 等,能够从 URL 获取 GraphQL 模式。 How can I get the schema with Python?如何使用 Python 获取模式?

This will create a json file with your schema.这将使用您的架构创建一个 json 文件。

import json

introspection_dict = your_schema_object.introspect()

# Or save the schema into some file
with open("schema.json", "w") as fp:
    json.dump(introspection_dict, fp)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM