Fix code examples in queries.rst#1265
Merged
firaskafri merged 3 commits intographql-python:mainfrom Sep 24, 2022
Merged
Conversation
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.
Contributor
Author
|
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'" |
Contributor
Author
|
Added two more commits that fix indentation in another block and add syntax highlighting for graphql queries in code blocks |
firaskafri
approved these changes
Sep 22, 2022
firaskafri
approved these changes
Sep 23, 2022
jkimbo
approved these changes
Sep 23, 2022
superlevure
pushed a commit
to loft-orbital/graphene-django
that referenced
this pull request
Jul 19, 2023
* 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. * Fix indentation in query examples * Enable syntax highlight for graphql queries
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 aQuerymethod, but it's indented as module-level function.