graphql-python / graphql-python/graphene

intelligible errors on schema creation.

Abierto
#1,315 1 comentario 0 reacciones 0 asignados Ver en GitHub
✨ enhancement
Lenguaje dominante
Python
Estrellas
8.2k
Forks
818
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

When creating a schema, if there is a problem with one of your QueryObjects, the resulting error message and traceback does not give any indication as to which ObjectType class is broken.

ex)
```
Traceback (most recent call last):
File "", line 1, in
File "/home/user/sonicsd/src/api/graphql.py", line 30, in schema
File "/usr/local/lib/python3.7/dist-packages/graphene/types/schema.py", line 78, in __init__
self.build_typemap()
File "/usr/local/lib/python3.7/dist-packages/graphene/types/schema.py", line 168, in build_typemap
initial_types, auto_camelcase=self.auto_camelcase, schema=self
File "/usr/local/lib/python3.7/dist-packages/graphene/types/typemap.py", line 80, in __init__
super(TypeMap, self).__init__(types)
File "/usr/local/lib/python3.7/dist-packages/graphql/type/typemap.py", line 31, in __init__
self.update(reduce(self.reducer, types, OrderedDict())) # type: ignore
File "/usr/local/lib/python3.7/dist-packages/graphene/types/typemap.py", line 88, in reducer
return self.graphene_reducer(map, type)
File "/usr/local/lib/python3.7/dist-packages/graphene/types/typemap.py", line 117, in graphene_reducer
return GraphQLTypeMap.reducer(map, internal_type)
File "/usr/local/lib/python3.7/dist-packages/graphql/type/typemap.py", line 109, in reducer
field_map = type_.fields
File "/usr/local/lib/python3.7/dist-packages/graphql/pyutils/cached_property.py", line 22, in __get__
value = obj.__dict__[self.func.__name__] = self.func(obj)
File "/usr/local/lib/python3.7/dist-packages/graphql/type/definition.py", line 198, in fields
return define_field_map(self, self._fields)
File "/usr/local/lib/python3.7/dist-packages/graphql/type/definition.py", line 217, in define_field_map
).format(type_)
AssertionError: Query fields must be a mapping (dict / OrderedDict) with field names as keys or a function which returns such a mapping.
```

In the error there should at least be the name of the Query class whose fields are invalid.
In this case I believe the error turned out to be that the root Query had no fields because I was improperly dynamically generating them.

Guía de contribución

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

Línea de trabajo

El traceback apunta a graphene/types/schema.py, graphene/types/typemap.py y graphql/type/definition.py; empieza siguiendo la creación del esquema hasta la validación de los campos de Query. Haz que los errores identifiquen la clase Query/ObjectType no válida y verifica que la excepción resultante incluya su nombre.

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

Evaluación

Stack tecnológico
python
Área
api, backend-api-design
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.