Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disambiguate argument name in quickstart docs #1474

Merged
merged 1 commit into from Nov 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 10 additions & 9 deletions docs/quickstart.rst
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