graphql.schema类型和python类的输入

发布于 2025-01-27 15:40:13 字数 313 浏览 2 评论 0原文

我目前正在使用用Python编写的AWS-APPSYNC和LAMBDA-resolvers来制作GraphQL API。在我的lambdas内,我只与DICC合作。随着项目规模的增长,在不了解GraphQl.schema的情况下,很难遵循逻辑。因此,我想使用我的GraphQL类型/输入的相应Python类表示。

我正在寻找一个简单的库,该库将类型和输入从我的GraphQl.Schema转换为Python类,最佳地利用了Pydantic之类的东西。

在网络上,我只找到了完整的客户端/服务器库,例如草莓和Ariadne。

是否存在满足我需求的图书馆,还是需要自己实施?

I am currently working on a GraphQL API using aws-appsync and lambda-resolvers written in python. Inside my lambdas, I am working with dicts only. With a growing project size, it becomes hard to follow the logic without knowledge of the graphql.schema. Therefore, I would like to use the corresponding python class representations of my GraphQL types/inputs.

I am looking for a simple library which transforms the types and inputs from my graphql.schema to python classes, optimally leveraging something like pydantic.

On the web, I only found full client/server libraries like for example Strawberry and Ariadne.

Does a library exist that satisfies my needs, or do I need to implement it on my own?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我一向站在原地 2025-02-03 15:40:13

我们可以使用 datamodel-code-generator 出于您的问题。代码生成器可以从GraphQL模式定义创建Pydantic模型。

或者我们可以使用我的旧项目 https://pypi.org/project/project/graphql2python/ (我建议使用DataModel代码生成器)。

We can using datamodel-code-generator for your problem. The code generator can create pydantic models from GraphQL schema definitions.

Or we can using my old project https://pypi.org/project/graphql2python/ for this (i recommended using datamodel-code-generator).

冷默言语 2025-02-03 15:40:13

不确定是否可以提供帮助,但是我刚刚发布了一种python-graphql映射器,在python对象中转换GraphQl响应(已声明了Python类及其字段),反之亦然。

https://github.com/dapalex/dapalex/py-graphql-mapper 仅管理基本查询和响应,如果它将变得有用,我将继续实现更多功能。

尝试看看,看看它是否可以帮助您

Not sure if it can help but I just published a kind of python-graphql mapper transforming graphql responses in Python objects (having declared the python class and it's fields) and vice versa.

https://github.com/dapalex/py-graphql-mapper

So far it manages only basic query and response, if it will become useful I will keep implementing more features.

Try to have a look and see if it can help you

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文