1
- from typing import Optional
1
+ from typing import Any , Dict , Optional
2
2
3
3
from .custom_fields import PostFields , UserFields
4
4
from .input_types import AddUserInput , UpdateUserInput
7
7
class Mutation :
8
8
@classmethod
9
9
def add_user (cls , user_input : AddUserInput ) -> UserFields :
10
- arguments = {"user_input" : {"type" : "AddUserInput!" , "value" : user_input }}
10
+ arguments : Dict [str , Dict [str , Any ]] = {
11
+ "user_input" : {"type" : "AddUserInput!" , "value" : user_input }
12
+ }
11
13
cleared_arguments = {
12
14
key : value for key , value in arguments .items () if value ["value" ] is not None
13
15
}
14
16
return UserFields (field_name = "addUser" , arguments = cleared_arguments )
15
17
16
18
@classmethod
17
19
def update_user (cls , user_id : str , user_input : UpdateUserInput ) -> UserFields :
18
- arguments = {
20
+ arguments : Dict [ str , Dict [ str , Any ]] = {
19
21
"user_id" : {"type" : "ID!" , "value" : user_id },
20
22
"user_input" : {"type" : "UpdateUserInput!" , "value" : user_input },
21
23
}
@@ -26,7 +28,9 @@ def update_user(cls, user_id: str, user_input: UpdateUserInput) -> UserFields:
26
28
27
29
@classmethod
28
30
def delete_user (cls , user_id : str ) -> UserFields :
29
- arguments = {"user_id" : {"type" : "ID!" , "value" : user_id }}
31
+ arguments : Dict [str , Dict [str , Any ]] = {
32
+ "user_id" : {"type" : "ID!" , "value" : user_id }
33
+ }
30
34
cleared_arguments = {
31
35
key : value for key , value in arguments .items () if value ["value" ] is not None
32
36
}
@@ -36,7 +40,7 @@ def delete_user(cls, user_id: str) -> UserFields:
36
40
def add_post (
37
41
cls , title : str , content : str , author_id : str , published_at : str
38
42
) -> PostFields :
39
- arguments = {
43
+ arguments : Dict [ str , Dict [ str , Any ]] = {
40
44
"title" : {"type" : "String!" , "value" : title },
41
45
"content" : {"type" : "String!" , "value" : content },
42
46
"authorId" : {"type" : "ID!" , "value" : author_id },
@@ -56,7 +60,7 @@ def update_post(
56
60
content : Optional [str ] = None ,
57
61
published_at : Optional [str ] = None
58
62
) -> PostFields :
59
- arguments = {
63
+ arguments : Dict [ str , Dict [ str , Any ]] = {
60
64
"post_id" : {"type" : "ID!" , "value" : post_id },
61
65
"title" : {"type" : "String" , "value" : title },
62
66
"content" : {"type" : "String" , "value" : content },
@@ -69,7 +73,9 @@ def update_post(
69
73
70
74
@classmethod
71
75
def delete_post (cls , post_id : str ) -> PostFields :
72
- arguments = {"post_id" : {"type" : "ID!" , "value" : post_id }}
76
+ arguments : Dict [str , Dict [str , Any ]] = {
77
+ "post_id" : {"type" : "ID!" , "value" : post_id }
78
+ }
73
79
cleared_arguments = {
74
80
key : value for key , value in arguments .items () if value ["value" ] is not None
75
81
}
0 commit comments