Skip to content

Fix code examples in queries.rst#1265

Merged
firaskafri merged 3 commits intographql-python:mainfrom
belkka:patch-1
Sep 24, 2022
Merged

Fix code examples in queries.rst#1265
firaskafri merged 3 commits intographql-python:mainfrom
belkka:patch-1

Conversation

@belkka
Copy link
Contributor

@belkka belkka commented Oct 12, 2021

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.

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.
@belkka
Copy link
Contributor Author

belkka commented Oct 12, 2021

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'"

@belkka
Copy link
Contributor Author

belkka commented Oct 12, 2021

Added two more commits that fix indentation in another block and add syntax highlighting for graphql queries in code blocks

@firaskafri firaskafri self-requested a review September 22, 2022 17:24
@firaskafri firaskafri closed this Sep 23, 2022
@firaskafri firaskafri reopened this Sep 23, 2022
@firaskafri firaskafri closed this Sep 24, 2022
@firaskafri firaskafri reopened this Sep 24, 2022
@firaskafri firaskafri merged commit 97442f9 into graphql-python:main Sep 24, 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants