File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -30,17 +30,17 @@ server with an associated set of resolve methods that know how to fetch
30
30
data.
31
31
32
32
We are going to create a very simple schema, with a ``Query `` with only
33
- one field: ``hello ``. And when we query it, it should return ``"World " ``.
33
+ one field: ``hello `` and an input name . And when we query it, it should return ``"Hello {name} " ``.
34
34
35
35
.. code :: python
36
36
37
37
import graphene
38
38
39
39
class Query (graphene .ObjectType ):
40
- hello = graphene.String()
40
+ hello = graphene.String(name = graphene.Argument(graphene.String, default_value = " stranger " ) )
41
41
42
42
def resolve_hello (self , args , context , info ):
43
- return ' World '
43
+ return ' Hello ' + args[ ' name ' ]
44
44
45
45
schema = graphene.Schema(query = Query)
46
46
@@ -52,6 +52,6 @@ Then we can start querying our schema:
52
52
.. code :: python
53
53
54
54
result = schema.execute(' { hello }' )
55
- print result.data[' hello' ] # "World "
55
+ print result.data[' hello' ] # "Hello stranger "
56
56
57
57
Congrats! You got your first graphene schema working!
You can’t perform that action at this time.
0 commit comments