@@ -25,42 +25,6 @@ developer has to write to use them.
25
25
26
26
## Deprecations
27
27
28
- ### Simpler resolvers
29
-
30
- All the resolvers in graphene have been simplified.
31
- Prior to Graphene ` 2.0 ` , all resolvers required four arguments: ` (root, args, context, info) ` .
32
- Now, resolver ` args ` are passed as keyword arguments to the function, and ` context ` argument dissapeared in favor of ` info.context ` .
33
-
34
- Before:
35
-
36
- ``` python
37
- my_field = graphene.String(my_arg = graphene.String())
38
-
39
- def resolve_my_field (self , args , context , info ):
40
- my_arg = args.get(' my_arg' )
41
- return ...
42
- ```
43
-
44
- With 2.0:
45
-
46
- ``` python
47
- my_field = graphene.String(my_arg = graphene.String())
48
-
49
- def resolve_my_field (self , info , my_arg ):
50
- return ...
51
- ```
52
-
53
- And, if you need the context in the resolver, you can use ` info.context ` :
54
-
55
- ``` python
56
- my_field = graphene.String(my_arg = graphene.String())
57
-
58
- def resolve_my_field (self , info , my_arg ):
59
- context = info.context
60
- return ...
61
- ```
62
-
63
-
64
28
### AbstractType deprecated
65
29
66
30
AbstractType is deprecated in graphene 2.0, you can now use normal inheritance instead.
@@ -135,9 +99,9 @@ class User(Mutation):
135
99
136
100
### Simpler resolvers
137
101
138
- All the resolvers in graphene have been simplified. If before resolvers required
139
- four arguments ` root ` , ` args ` , ` context ` and ` info ` , now the ` args ` are passed as keyword arguments
140
- and ` context ` and ` info ` will only be passed if the function is annotated with it .
102
+ All the resolvers in graphene have been simplified.
103
+ Prior to Graphene ` 2.0 ` , all resolvers required four arguments: ` (root, args, context, info) ` .
104
+ Now, resolver ` args ` are passed as keyword arguments to the function, and ` context ` argument dissapeared in favor of ` info.context ` .
141
105
142
106
Before:
143
107
@@ -154,26 +118,17 @@ With 2.0:
154
118
``` python
155
119
my_field = graphene.String(my_arg = graphene.String())
156
120
157
- def resolve_my_field (self , my_arg ):
158
- return ...
159
- ```
160
-
161
- And, if the resolver want to receive the context:
162
-
163
- ``` python
164
- my_field = graphene.String(my_arg = graphene.String())
165
-
166
- def resolve_my_field (self , context : graphene.Context, my_arg ):
121
+ def resolve_my_field (self , info , my_arg ):
167
122
return ...
168
123
```
169
124
170
- which is equivalent in Python 2 to :
125
+ And, if you need the context in the resolver, you can use ` info.context ` :
171
126
172
127
``` python
173
128
my_field = graphene.String(my_arg = graphene.String())
174
129
175
- @annotate ( context = graphene.Context)
176
- def resolve_my_field ( self , context , my_arg ):
130
+ def resolve_my_field ( self , info , my_arg ):
131
+ context = info.context
177
132
return ...
178
133
```
179
134
0 commit comments