Skip to content

Commit

Permalink
docs: Disambiguate argument name in quickstart docs (#1474)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgroothuijsen committed Nov 16, 2022
1 parent a2b63d8 commit f891a36
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ An example in Graphene

Let’s build a basic GraphQL schema to say "hello" and "goodbye" in Graphene.

When we send a **Query** requesting only one **Field**, ``hello``, and specify a value for the ``name`` **Argument**...
When we send a **Query** requesting only one **Field**, ``hello``, and specify a value for the ``firstName`` **Argument**...

.. code::
{
hello(name: "friend")
hello(firstName: "friend")
}
...we would expect the following Response containing only the data requested (the ``goodbye`` field is not resolved).
Expand Down Expand Up @@ -79,14 +79,15 @@ In Graphene, we can define a simple schema using the following code:
from graphene import ObjectType, String, Schema
class Query(ObjectType):
# this defines a Field `hello` in our Schema with a single Argument `name`
hello = String(name=String(default_value="stranger"))
# this defines a Field `hello` in our Schema with a single Argument `first_name`
# By default, the argument name will automatically be camel-based into firstName in the generated schema
hello = String(first_name=String(default_value="stranger"))
goodbye = String()
# our Resolver method takes the GraphQL context (root, info) as well as
# Argument (name) for the Field and returns data for the query Response
def resolve_hello(root, info, name):
return f'Hello {name}!'
# Argument (first_name) for the Field and returns data for the query Response
def resolve_hello(root, info, first_name):
return f'Hello {first_name}!'
def resolve_goodbye(root, info):
return 'See ya!'
Expand All @@ -110,7 +111,7 @@ In the `GraphQL Schema Definition Language`_, we could describe the fields defin
.. code::
type Query {
hello(name: String = "stranger"): String
hello(firstName: String = "stranger"): String
goodbye: String
}
Expand All @@ -130,7 +131,7 @@ Then we can start querying our **Schema** by passing a GraphQL query string to `
# "Hello stranger!"
# or passing the argument in the query
query_with_argument = '{ hello(name: "GraphQL") }'
query_with_argument = '{ hello(firstName: "GraphQL") }'
result = schema.execute(query_with_argument)
print(result.data['hello'])
# "Hello GraphQL!"
Expand Down

0 comments on commit f891a36

Please sign in to comment.