mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-10 19:57:15 +03:00
Fix code examples in queries.rst (#1265)
* 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
This commit is contained in:
parent
60b3032014
commit
97442f9cee
|
@ -151,7 +151,7 @@ For example the following ``Model`` and ``DjangoObjectType``:
|
|||
|
||||
Results in the following GraphQL schema definition:
|
||||
|
||||
.. code::
|
||||
.. code:: graphql
|
||||
|
||||
type Pet {
|
||||
id: ID!
|
||||
|
@ -178,7 +178,7 @@ You can disable this automatic conversion by setting
|
|||
fields = ("id", "kind",)
|
||||
convert_choices_to_enum = False
|
||||
|
||||
.. code::
|
||||
.. code:: graphql
|
||||
|
||||
type Pet {
|
||||
id: ID!
|
||||
|
@ -313,7 +313,7 @@ Additionally, Resolvers will receive **any arguments declared in the field defin
|
|||
bar=graphene.Int()
|
||||
)
|
||||
|
||||
def resolve_question(root, info, foo, bar):
|
||||
def resolve_question(root, info, foo=None, bar=None):
|
||||
# If `foo` or `bar` are declared in the GraphQL query they will be here, else None.
|
||||
return Question.objects.filter(foo=foo, bar=bar).first()
|
||||
|
||||
|
@ -418,7 +418,7 @@ the core graphene pages for more information on customizing the Relay experience
|
|||
You can now execute queries like:
|
||||
|
||||
|
||||
.. code:: python
|
||||
.. code:: graphql
|
||||
|
||||
{
|
||||
questions (first: 2, after: "YXJyYXljb25uZWN0aW9uOjEwNQ==") {
|
||||
|
@ -440,7 +440,7 @@ You can now execute queries like:
|
|||
|
||||
Which returns:
|
||||
|
||||
.. code:: python
|
||||
.. code:: json
|
||||
|
||||
{
|
||||
"data": {
|
||||
|
|
Loading…
Reference in New Issue
Block a user