@@ -118,29 +118,34 @@ def type(self):
118
118
).format (str (self ), connection_type )
119
119
return connection_type
120
120
121
+ @classmethod
122
+ def resolve_connection (cls , connection_type , args , resolved ):
123
+ if isinstance (resolved , connection_type ):
124
+ return resolved
125
+
126
+ assert isinstance (resolved , Iterable ), (
127
+ 'Resolved value from the connection field have to be iterable or instance of {}. '
128
+ 'Received "{}"'
129
+ ).format (connection_type , resolved )
130
+ connection = connection_from_list (
131
+ resolved ,
132
+ args ,
133
+ connection_type = connection_type ,
134
+ edge_type = connection_type .Edge ,
135
+ pageinfo_type = PageInfo
136
+ )
137
+ connection .iterable = resolved
138
+ return connection
139
+
121
140
@classmethod
122
141
def connection_resolver (cls , resolver , connection_type , root , args , context , info ):
123
- p = Promise .resolve (resolver (root , args , context , info ))
124
-
125
- def resolve_connection (resolved ):
126
- if isinstance (resolved , connection_type ):
127
- return resolved
128
-
129
- assert isinstance (resolved , Iterable ), (
130
- 'Resolved value from the connection field have to be iterable or instance of {}. '
131
- 'Received "{}"'
132
- ).format (connection_type , resolved )
133
- connection = connection_from_list (
134
- resolved ,
135
- args ,
136
- connection_type = connection_type ,
137
- edge_type = connection_type .Edge ,
138
- pageinfo_type = PageInfo
139
- )
140
- connection .iterable = resolved
141
- return connection
142
-
143
- return p .then (resolve_connection )
142
+ resolved = resolver (root , args , context , info )
143
+
144
+ on_resolve = partial (cls .resolve_connection , connection_type , args )
145
+ if isinstance (resolved , Promise ):
146
+ return resolved .then (on_resolve )
147
+
148
+ return on_resolve (resolved )
144
149
145
150
def get_resolver (self , parent_resolver ):
146
151
resolver = super (IterableConnectionField , self ).get_resolver (parent_resolver )
0 commit comments