graphql-python / graphql-python/graphene

Unclear documentation for ObjectType

Abierto
#1,290 4 comentarios 3 reacciones 0 asignados Ver en GitHub
🐛 bug
Lenguaje dominante
Python
Estrellas
8.2k
Forks
818
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

* **What is the current behavior?**

The current [documentation for ObjectType](https://docs.graphene-python.org/en/latest/types/objecttypes/) states the following under the "Parent Value Object" heading:

```
from graphene import ObjectType, String, Field

class Person(ObjectType):
full_name = String()

def resolve_full_name(parent, info):
return f"{parent.first_name} {parent.last_name}"

class Query(ObjectType):
me = Field(Person)

def resolve_me(parent, info):
# returns an object that represents a Person
return get_human(name="Luke Skywalker")
```

- **If the current behavior is a bug, please provide the steps to reproduce**

If you copy this directly into PyCharm (or any other editor I would imagine) you get an error stating that the function get_human cannot be located.

I am currently trying to write my own ObjectType which will take an argument. However, because the documentation cannot be run, I don't know how to proceed.

I have the following:

```
class RunLog(ObjectType):
status = String()
result = String()
log = List(String)

def resolve_status(self, resolve, run_id):
return r.hget("run:%i" % run_id, "status").decode('utf-8')

def resolve_result(self, resolve, run_id):
return r.hget("run:%i" % run_id, "result").decode('utf-8')

def resolve_log(self, resolve, run_id):
log_data = r.lrange("run:%i:log" % run_id, 0, -1)
log_data = [entry.decode('utf-8') for entry in log_data]

return log_data

class Query(ObjectType):
log_by_run_id = Field(RunLog, run_id=Int(required=True))

# @login_required
def resolve_log_by_run_id(root, info, run_id):
return **?????**
```

Because the documentation references an unknown function, I don't know what to put in the final line as the return value for resolve_log_by_run_id.

This type of unknown function of class seems to appear a lot in the documentation. It can be seen again under [Executing a query](https://docs.graphene-python.org/en/latest/execution/execute/#schemaexecute).

* **What is the expected behavior?**

The documentation can be clearly interoperated.

Guía de contribución

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

Línea de trabajo

Comienza con la sección «Parent Value Object» de la documentación de ObjectType y con el ejemplo «Executing a query» enlazado en el issue. Revisa cada función no documentada o marcador de posición y haz que los ejemplos se puedan ejecutar, o explica los valores definidos por la aplicación que se requieren, incluido lo que debería devolver resolve_log_by_run_id. Se considera terminado cuando un lector puede interpretar y seguir los ejemplos sin que funciones desconocidas se lo impidan.

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

Evaluación

Stack tecnológico
python
Área
documentation
Tipo de issue
Documentación
Dificultad
2/5
Tiempo estimado
1-3 horas
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.