graphene-django
graphene-django copied to clipboard
Fix code examples in queries.rst
Code example in Arguments section doesn't work as stated in its comment — if "foo" or "bar" are not declare in the graphql query, it will be an error, not they become None.
Code example in Info section has invalid indentation, resolve_questions() seems to be a Query method, but it's indented as module-level function.
And explanation why first of edited code examples doesn't work properly:
import graphene
class Query(graphene.ObjectType):
question = graphene.Field(
graphene.String,
foo=graphene.String(),
bar=graphene.Int()
)
def resolve_question(root, info, foo, bar):
# If `foo` or `bar` are declared in the GraphQL query they will be here, else None.
return str(foo) + str(bar)
result = graphene.Schema(query=Query).execute('{question}')
error, = result.errors
assert error.message == "resolve_question() missing 2 required positional arguments: 'foo' and 'bar'"
Added two more commits that fix indentation in another block and add syntax highlighting for graphql queries in code blocks