Support OneOf input object types
还没有人认领这个 Issue。
评估
调研方向
Start at InputObjectType metadata handling and schema construction, then trace how GraphQLInputObjectType is created from the declared Meta options. Check graphql-core's is_one_of support and verify that the completed integration exposes isOneOf through introspection and enforces exactly one non-null member during input coercion.
由索引模型根据 Issue 内容生成。
描述
Is your feature request related to a problem? Please describe.
Graphene cannot currently express a GraphQL OneOf input object. This commonly arises when an input accepts one of several typed alternatives: defining every alternative as an optional field neither communicates the exactly-one constraint through the schema nor lets GraphQL enforce it during input coercion.
Related requests for input unions or heterogeneous input types have appeared in #721, #797, and #1228. PR #1342 proposed resolver-level validation for a similar exactly-one constraint, but that does not expose the constraint in the GraphQL type system.
Describe the solution you'd like
Allow an InputObjectType to opt into OneOf semantics through its metadata:
class PetInput(graphene.InputObjectType):
class Meta:
one_of = True
cat = graphene.InputField(CatInput)
dog = graphene.InputField(DogInput)
Graphene would pass this metadata through to graphql-core as GraphQLInputObjectType(is_one_of=True). graphql-core can then expose isOneOf through introspection and enforce OneOf schema and input-coercion rules, including requiring exactly one non-null member value.
Describe alternatives you've considered
Applications can validate optional fields in resolvers or use a custom decorator like the approach proposed in #1342. Those approaches duplicate validation, run later than GraphQL input coercion, and do not make the constraint visible to clients through schema introspection.
Additional context
OneOf input objects are now part of the GraphQL specification, and current graphql-core releases already provide the underlying is_one_of support. Graphene needs a public declaration mechanism and schema-construction integration to expose it.
- 主要语言
- Python
- 星标
- 8.2k
- 派生
- 822
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
graphql-python/graphene 的其他 Issue
-
🐛 bug
难度 2/5 1-3 小时 新手友好度 72/100
graphql-python/graphene#1389 · 5 条评论 · 2 个 reaction ·
-
✨ enhancement
难度 2/5 1-3 小时 新手友好度 38/100
graphql-python/graphene#1601 · 2 条评论 ·
-
✨ enhancement
难度 4/5 3-5 天 新手友好度 42/100
graphql-python/graphene#1600 ·
-
Inaccurate Float-to-Decimal Conversion in `parse_value` of `Decimal` `Scalar`可能已有人在做 @mak626 于 609 天前认领。 未关闭🐛 bug
难度 2/5 1-3 小时 新手友好度 55/100
graphql-python/graphene#1593 ·
-
🐛 bug
难度 4/5 3-5 天 新手友好度 25/100
graphql-python/graphene#1592 ·
查看 graphql-python/graphene 的全部 Issue
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 87/100
adri0/scadustats#128 ·
维护者通常 1 天内回复
-
`TIMESTAMP`, `TIMESTAMP_NTZ`, `TINYINT` and the other `TypeDecorator`s don't declare `python_type`未关闭
难度 2/5 1-3 小时 新手友好度 78/100
-
RPBC未关闭awaiting policy acceptance precheck-passed
难度 1/5 1 小时以内 新手友好度 78/100
Bioconductor/BiocContributions#240 · 1 条评论 ·
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
documentation good first issue launch
难度 2/5 1-3 小时 新手友好度 83/100
FlologixAI/etchwork#4 ·