File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -30,17 +30,18 @@ server with an associated set of resolve methods that know how to fetch
3030data.
3131
3232We are going to create a very simple schema, with a ``Query `` with only
33- one field: ``hello `` and an input name. And when we query it, it should return ``"Hello {name}" ``.
33+ one field: ``hello `` and an input name. And when we query it, it should return ``"Hello
34+ {argument}" ``.
3435
3536.. code :: python
3637
3738 import graphene
3839
3940 class Query (graphene .ObjectType ):
40- hello = graphene.String(name = graphene.String(default_value = " stranger" ))
41+ hello = graphene.String(argument = graphene.String(default_value = " stranger" ))
4142
42- def resolve_hello (self , info , name ):
43- return ' Hello ' + name
43+ def resolve_hello (self , info , argument ):
44+ return ' Hello ' + argument
4445
4546 schema = graphene.Schema(query = Query)
4647
@@ -54,4 +55,8 @@ Then we can start querying our schema:
5455 result = schema.execute(' { hello }' )
5556 print (result.data[' hello' ]) # "Hello stranger"
5657
58+ # or passing the argument in the query
59+ result = schema.execute(' { hello (argument: "graph") }' )
60+ print (result.data[' hello' ]) # "Hello graph"
61+
5762 Congrats! You got your first graphene schema working!
You can’t perform that action at this time.
0 commit comments