|
1 |
| -from collections import Iterable |
2 |
| - |
3 |
| -from graphql_relay.connection.arrayconnection import connection_from_list |
4 | 1 | from graphql_relay.node.node import from_global_id
|
5 | 2 |
|
6 | 3 | from ..core.fields import Field
|
@@ -30,24 +27,11 @@ def wrap_resolved(self, value, instance, args, info):
|
30 | 27 | return value
|
31 | 28 |
|
32 | 29 | def resolver(self, instance, args, info):
|
33 |
| - from graphene.relay.types import PageInfo |
34 | 30 | schema = info.schema.graphene_schema
|
35 |
| - |
| 31 | + connection_type = self.get_type(schema) |
36 | 32 | resolved = super(ConnectionField, self).resolver(instance, args, info)
|
37 |
| - if resolved: |
38 |
| - resolved = self.wrap_resolved(resolved, instance, args, info) |
39 |
| - assert isinstance( |
40 |
| - resolved, Iterable), 'Resolved value from the connection field have to be iterable' |
41 |
| - type = schema.T(self.type) |
42 |
| - node = schema.objecttype(type) |
43 |
| - connection_type = self.get_connection_type(node) |
44 |
| - edge_type = self.get_edge_type(node) |
45 |
| - |
46 |
| - connection = connection_from_list( |
47 |
| - resolved, args, connection_type=connection_type, |
48 |
| - edge_type=edge_type, pageinfo_type=PageInfo) |
49 |
| - connection.set_connection_data(resolved) |
50 |
| - return connection |
| 33 | + if not isinstance(resolved, connection_type): |
| 34 | + return connection_type.from_list(resolved, args, info) |
51 | 35 |
|
52 | 36 | def get_connection_type(self, node):
|
53 | 37 | connection_type = self.connection_type or node.get_connection_type()
|
|
0 commit comments