You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Revise documentation
- Add missing reference to `flask-graphql` in integrations
- align documentation for resolver arguments (use root for 1st argument
instead of self)
- explore use of `parent` instead of `root` for first argument
- clarify resolvers and object type documentation
- add documentation for Meta class options for ObjectType
- expand quickstart documentation for first time users
- streamline order of documentation for first time users (broad ->
specific)
- document resolver quirks
* explict imports from graphene
* rename doc refs for resolvers
* suggestions typos and graphene import
Copy file name to clipboardExpand all lines: UPGRADE-v1.0.md
+13-17Lines changed: 13 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -2,30 +2,29 @@
2
2
3
3
Big changes from v0.10.x to 1.0. While on the surface a lot of this just looks like shuffling around API, the entire codebase has been rewritten to handle some really great use cases and improved performance.
4
4
5
-
6
5
## Backwards Compatibility and Deprecation Warnings
7
6
8
7
This has been a community project from the start, we need your help making the upgrade as smooth as possible for everybody!
9
8
We have done our best to provide backwards compatibility with deprecated APIs.
10
9
11
-
12
10
## Deprecations
13
11
14
-
*`with_context` is no longer needed. Resolvers now always take the context argument.
12
+
-`with_context` is no longer needed. Resolvers now always take the context argument.
15
13
Before:
16
14
17
15
```python
18
-
defresolve_xxx(self, args, info):
16
+
defresolve_xxx(root, args, info):
19
17
# ...
20
18
```
21
19
22
20
With 1.0:
21
+
23
22
```python
24
-
defresolve_xxx(self, args, context, info):
23
+
defresolve_xxx(root, args, context, info):
25
24
# ...
26
25
```
27
26
28
-
*`ObjectType` and `Interface` no longer accept the `abstract` option in the `Meta`.
27
+
-`ObjectType` and `Interface` no longer accept the `abstract` option in the `Meta`.
29
28
Inheriting fields should be now achieved using `AbstractType` inheritance.
30
29
31
30
Before:
@@ -42,6 +41,7 @@ We have done our best to provide backwards compatibility with deprecated APIs.
42
41
```
43
42
44
43
With 1.0:
44
+
45
45
```python
46
46
classMyBaseQuery(graphene.AbstractType):
47
47
my_field = String()
@@ -50,9 +50,9 @@ We have done our best to provide backwards compatibility with deprecated APIs.
50
50
pass
51
51
```
52
52
53
-
* The `type_name` option in the Meta in types is now `name`
53
+
- The `type_name` option in the Meta in types is now `name`
54
54
55
-
* Type references no longer work with strings, but with functions.
55
+
- Type references no longer work with strings, but with functions.
56
56
57
57
Before:
58
58
@@ -70,7 +70,6 @@ We have done our best to provide backwards compatibility with deprecated APIs.
70
70
users = graphene.List(lambda: User)
71
71
```
72
72
73
-
74
73
## Schema
75
74
76
75
Schemas in graphene `1.0` are `Immutable`, that means that once you create a `graphene.Schema` any
@@ -80,7 +79,6 @@ The `name` argument is removed from the Schema.
80
79
The arguments `executor` and `middlewares` are also removed from the `Schema` definition.
81
80
You can still use them, but by calling explicitly in the `execute` method in `graphql`.
82
81
83
-
84
82
```python
85
83
# Old way
86
84
schema = graphene.Schema(name='My Schema')
@@ -94,7 +92,6 @@ schema = graphene.Schema(
94
92
)
95
93
```
96
94
97
-
98
95
## Interfaces
99
96
100
97
For implementing an Interface in an ObjectType, you have to add it onto `Meta.interfaces`.
@@ -131,7 +128,7 @@ class ReverseString(Mutation):
131
128
132
129
reversed= String()
133
130
134
-
defmutate(self, args, context, info):
131
+
defmutate(root, args, context, info):
135
132
reversed= args.get('input')[::-1]
136
133
return ReverseString(reversed=reversed)
137
134
@@ -158,14 +155,13 @@ class Query(ObjectType):
158
155
Also, if you wanted to create an `ObjectType` that implements `Node`, you have to do it
159
156
explicity.
160
157
161
-
162
158
## Django
163
159
164
160
The Django integration with Graphene now has an independent package: `graphene-django`.
165
161
For installing, you have to replace the old `graphene[django]` with `graphene-django`.
166
162
167
-
* As the package is now independent, you now have to import from `graphene_django`.
168
-
***DjangoNode no longer exists**, please use `relay.Node` instead:
163
+
- As the package is now independent, you now have to import from `graphene_django`.
164
+
-**DjangoNode no longer exists**, please use `relay.Node` instead:
169
165
170
166
```python
171
167
from graphene.relay import Node
@@ -181,8 +177,8 @@ For installing, you have to replace the old `graphene[django]` with `graphene-dj
181
177
The SQLAlchemy integration with Graphene now has an independent package: `graphene-sqlalchemy`.
182
178
For installing, you have to replace the old `graphene[sqlalchemy]` with `graphene-sqlalchemy`.
183
179
184
-
* As the package is now independent, you have to import now from `graphene_sqlalchemy`.
185
-
***SQLAlchemyNode no longer exists**, please use `relay.Node` instead:
180
+
- As the package is now independent, you have to import now from `graphene_sqlalchemy`.
181
+
-**SQLAlchemyNode no longer exists**, please use `relay.Node` instead:
Copy file name to clipboardExpand all lines: UPGRADE-v2.0.md
+35-37Lines changed: 35 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -7,20 +7,22 @@ It also improves the field resolvers, [simplifying the code](#simpler-resolvers)
7
7
developer has to write to use them.
8
8
9
9
**Deprecations:**
10
-
*[`AbstractType`](#abstracttype-deprecated)
11
-
*[`resolve_only_args`](#resolve_only_args)
12
-
*[`Mutation.Input`](#mutationinput)
10
+
11
+
-[`AbstractType`](#abstracttype-deprecated)
12
+
-[`resolve_only_args`](#resolve_only_args)
13
+
-[`Mutation.Input`](#mutationinput)
13
14
14
15
**Breaking changes:**
15
-
*[`Simpler Resolvers`](#simpler-resolvers)
16
-
*[`Node Connections`](#node-connections)
16
+
17
+
-[`Simpler Resolvers`](#simpler-resolvers)
18
+
-[`Node Connections`](#node-connections)
17
19
18
20
**New Features!**
19
-
*[`InputObjectType`](#inputobjecttype)
20
-
*[`Meta as Class arguments`](#meta-as-class-arguments) (_only available for Python 3_)
21
21
22
+
-[`InputObjectType`](#inputobjecttype)
23
+
-[`Meta as Class arguments`](#meta-as-class-arguments) (_only available for Python 3_)
22
24
23
-
> The type metaclasses are now deleted as they are no longer necessary. If your code was depending
25
+
> The type metaclasses are now deleted as they are no longer necessary. If your code was depending
24
26
> on this strategy for creating custom attrs, see an [example on how to do it in 2.0](https://github.com/graphql-python/graphene/blob/v2.0.0/graphene/tests/issues/test_425.py).
25
27
26
28
## Deprecations
@@ -49,7 +51,7 @@ class Pet(CommonFields, Interface):
49
51
pass
50
52
```
51
53
52
-
### resolve\_only\_args
54
+
### resolve_only_args
53
55
54
56
`resolve_only_args` is now deprecated as the resolver API has been simplified.
**PS.: Take care with receiving args like `my_arg` as above. This doesn't work for optional (non-required) arguments as stantard `Connection`'s arguments (first, before, after, before).**
126
127
You may need something like this:
127
128
128
129
```python
129
-
defresolve_my_field(self, info, known_field1, known_field2, **args): ## get other args with: args.get('arg_key')
130
+
defresolve_my_field(root, info, known_field1, known_field2, **args): ## get other args with: args.get('arg_key')
130
131
```
131
132
132
133
And, if you need the context in the resolver, you can use `info.context`:
The parameters' order of `get_node_from_global_id` method has changed. You may need to adjust your [Node Root Field](http://docs.graphene-python.org/en/latest/relay/nodes/#node-root-field) and maybe other places that uses this method to obtain an object.
0 commit comments