Root Value example doesn't work
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 55/100
- Tipo di issue
- Documentazione
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- documentation
Direzione di ricerca
Inizia dalla sezione collegata «Root Value» nella documentazione ed esamina l’esempio completo che la circonda. Rendi coerenti la definizione di User, il nome del campo, il nome del resolver, il campo richiesto e i valori di esempio, in modo che l’esempio sia autonomo ed eseguibile; verifica l’esempio documentato dopo la modifica.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The Root Value example in the documentation:
from graphene import ObjectType, Field, Schema
class Query(ObjectType):
me = Field(User)
def resolve_user(root, info):
return {'id': root.id, 'firstName': root.name}
schema = Schema(Query)
user_root = User(id=12, name='bob')
result = schema.execute(
'''
query getUser {
user {
id
firstName
lastName
}
}
''',
root=user_root
)
assert result.data['user']['id'] == user_root.id
doesn't work. Throws NameError: name 'User' is not defined.
What's not clear is:
- Where
Useris defined -- is it defined somewhere else in the documentation? (hyperlink/inline) - The
Queryfield is namedmeyet the resolver function is namedresolve_user. - The executed query asks for
user(notme). - The created
Userobject (assigned touser_root) is constructed to have anamefield, yet the query asks for thefirstNameandlastNamefields. Sure,resolve_userreturns a dict withid, andfirstName, but this adds to the confusion.
Having various combinations of name, firstName and lastName is confusing, especially in an example that doesn't work.
- Lingua principale
- Python
- Stelle
- 8.2k
- Fork
- 818
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di graphql-python/graphene
-
Tutorial mistakes Aperta🐛 bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
graphql-python/graphene#1389 · 5 commenti · 2 reazioni ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
graphql-python/graphene#1606 ·
-
Python 3.14 support Aperta✨ enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 38/100
graphql-python/graphene#1601 · 2 commenti ·
-
✨ enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
graphql-python/graphene#1600 ·
-
🐛 bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 55/100
graphql-python/graphene#1593 ·
Tutte le issue di graphql-python/graphene
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
stephrobert/dsoxlab#238 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
sublimehq/package_control#1780 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
nwg-piotr/nwg-displays#145 ·