@@ -160,6 +160,8 @@ def __init__(
160
160
extra_sqlalchemy_type_to_strawberry_type_map : Optional [
161
161
Mapping [Type [TypeEngine ], Type [Any ]]
162
162
] = None ,
163
+ edge_type : Optional [Type ] = None ,
164
+ connection_type : Optional [Type ] = None ,
163
165
) -> None :
164
166
if model_to_type_name is None :
165
167
model_to_type_name = self ._default_model_to_type_name
@@ -181,6 +183,9 @@ def __init__(
181
183
self ._related_type_models = set ()
182
184
self ._related_interface_models = set ()
183
185
186
+ self .edge_type = edge_type
187
+ self .connection_type = connection_type
188
+
184
189
@staticmethod
185
190
def _default_model_to_type_name (model : Type [BaseModelType ]) -> str :
186
191
return model .__name__
@@ -220,6 +225,8 @@ def _edge_type_for(self, type_name: str) -> Type[Any]:
220
225
Get or create a corresponding Edge model for the given type
221
226
(to support future pagination)
222
227
"""
228
+ if self .edge_type is not None :
229
+ return self .edge_type
223
230
edge_name = f"{ type_name } Edge"
224
231
if edge_name not in self .edge_types :
225
232
self .edge_types [edge_name ] = edge_type = strawberry .type (
@@ -238,6 +245,8 @@ def _connection_type_for(self, type_name: str) -> Type[Any]:
238
245
Get or create a corresponding Connection model for the given type
239
246
(to support future pagination)
240
247
"""
248
+ if self .connection_type is not None :
249
+ return self .connection_type [ForwardRef (type_name )]
241
250
connection_name = f"{ type_name } Connection"
242
251
if connection_name not in self .connection_types :
243
252
self .connection_types [connection_name ] = connection_type = strawberry .type (
@@ -269,6 +278,8 @@ def _convert_column_to_strawberry_type(
269
278
"""
270
279
if isinstance (column .type , Enum ):
271
280
type_annotation = column .type .python_type
281
+ if not hasattr (column .type , "_enum_definition" ):
282
+ type_annotation = strawberry .enum (type_annotation )
272
283
elif isinstance (column .type , ARRAY ):
273
284
item_type = self ._convert_column_to_strawberry_type (
274
285
Column (column .type .item_type , nullable = False )
0 commit comments