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
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 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}" ``.
34
35
35
36
.. code :: python
36
37
37
38
import graphene
38
39
39
40
class Query (graphene .ObjectType ):
40
- hello = graphene.String(name = graphene.String(default_value = " stranger" ))
41
+ hello = graphene.String(argument = graphene.String(default_value = " stranger" ))
41
42
42
- def resolve_hello (self , info , name ):
43
- return ' Hello ' + name
43
+ def resolve_hello (self , info , argument ):
44
+ return ' Hello ' + argument
44
45
45
46
schema = graphene.Schema(query = Query)
46
47
@@ -54,4 +55,8 @@ Then we can start querying our schema:
54
55
result = schema.execute(' { hello }' )
55
56
print (result.data[' hello' ]) # "Hello stranger"
56
57
58
+ # or passing the argument in the query
59
+ result = schema.execute(' { hello (argument: "graph") }' )
60
+ print (result.data[' hello' ]) # "Hello graph"
61
+
57
62
Congrats! You got your first graphene schema working!
You can’t perform that action at this time.
0 commit comments