Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Support OneOf input object types

Abierto
#1,606 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
68/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
api

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
8.2k
Forks
818
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de graphql-python/graphene

Todos los issues de graphql-python/graphene

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.