Fixed Connection side effects and add into breaking changes.

This commit is contained in:
Syrus Akbary 2017-07-12 21:53:35 -07:00
parent f1624af08a
commit ec5697b185
2 changed files with 34 additions and 4 deletions

View File

@ -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)
```

View File

@ -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)