mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-22 17:46:57 +03:00
Fixed Connection side effects and add into breaking changes.
This commit is contained in:
parent
f1624af08a
commit
ec5697b185
|
@ -47,3 +47,36 @@
|
||||||
class Dog(ObjectType, interfaces=[Pet]):
|
class Dog(ObjectType, interfaces=[Pet]):
|
||||||
name = String()
|
name = String()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Breaking Changes
|
||||||
|
|
||||||
|
* Node types no longer have a `Connection` by default.
|
||||||
|
In 2.0 and onwoards `Connection`s should be defined explicitly.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```python
|
||||||
|
class User(ObjectType):
|
||||||
|
class Meta:
|
||||||
|
interfaces = [relay.Node]
|
||||||
|
name = String()
|
||||||
|
|
||||||
|
class Query(ObjectType):
|
||||||
|
user_connection = relay.ConnectionField(User)
|
||||||
|
```
|
||||||
|
|
||||||
|
With 2.0:
|
||||||
|
|
||||||
|
```python
|
||||||
|
class User(ObjectType):
|
||||||
|
class Meta:
|
||||||
|
interfaces = [relay.Node]
|
||||||
|
name = String()
|
||||||
|
|
||||||
|
class UserConnection(relay.Connection):
|
||||||
|
class Meta:
|
||||||
|
node = User
|
||||||
|
|
||||||
|
class Query(ObjectType):
|
||||||
|
user_connection = relay.ConnectionField(UserConnection)
|
||||||
|
```
|
||||||
|
|
|
@ -98,10 +98,7 @@ class IterableConnectionField(Field):
|
||||||
@property
|
@property
|
||||||
def type(self):
|
def type(self):
|
||||||
type = super(IterableConnectionField, self).type
|
type = super(IterableConnectionField, self).type
|
||||||
if is_node(type):
|
connection_type = type
|
||||||
connection_type = type.Connection
|
|
||||||
else:
|
|
||||||
connection_type = type
|
|
||||||
assert issubclass(connection_type, Connection), (
|
assert issubclass(connection_type, Connection), (
|
||||||
'{} type have to be a subclass of Connection. Received "{}".'
|
'{} type have to be a subclass of Connection. Received "{}".'
|
||||||
).format(self.__class__.__name__, connection_type)
|
).format(self.__class__.__name__, connection_type)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user