File tree 2 files changed +31
-1
lines changed
2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 6
6
class Query (links .schema .Query , graphene .ObjectType ):
7
7
pass
8
8
9
+ class Mutation (links .schema .Mutation , graphene .ObjectType ):
10
+ pass
9
11
10
- schema = graphene .Schema (query = Query )
12
+ schema = graphene .Schema (query = Query , mutation = Mutation )
Original file line number Diff line number Diff line change @@ -14,3 +14,31 @@ class Query(graphene.ObjectType):
14
14
15
15
def resolve_links (self , info , ** kwargs ):
16
16
return Link .objects .all ()
17
+
18
+
19
+ #1
20
+ class CreateLink (graphene .Mutation ):
21
+ id = graphene .Int ()
22
+ url = graphene .String ()
23
+ description = graphene .String ()
24
+
25
+ #2
26
+ class Arguments :
27
+ url = graphene .String ()
28
+ description = graphene .String ()
29
+
30
+ #3
31
+ def mutate (self , info , url , description ):
32
+ link = Link (url = url , description = description )
33
+ link .save ()
34
+
35
+ return CreateLink (
36
+ id = link .id ,
37
+ url = link .url ,
38
+ description = link .description ,
39
+ )
40
+
41
+
42
+ #4
43
+ class Mutation (graphene .ObjectType ):
44
+ create_link = CreateLink .Field ()
You can’t perform that action at this time.
0 commit comments