File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -1199,3 +1199,30 @@ async def test_additional_filters(session):
1199
1199
schema = graphene .Schema (query = Query )
1200
1200
result = await schema .execute_async (query , context_value = {"session" : session })
1201
1201
assert_and_raise_result (result , expected )
1202
+
1203
+
1204
+ @pytest .mark .asyncio
1205
+ async def test_do_not_create_filters ():
1206
+ class WithoutFilters (SQLAlchemyObjectType ):
1207
+ class Meta :
1208
+ abstract = True
1209
+
1210
+ @classmethod
1211
+ def __init_subclass_with_meta__ (cls , _meta = None , ** options ):
1212
+ super ().__init_subclass_with_meta__ (
1213
+ _meta = _meta , create_filters = False , ** options
1214
+ )
1215
+
1216
+ class PetType (WithoutFilters ):
1217
+ class Meta :
1218
+ model = Pet
1219
+ name = "Pet"
1220
+ interfaces = (relay .Node ,)
1221
+ connection_class = Connection
1222
+
1223
+ class Query (graphene .ObjectType ):
1224
+ pets = SQLAlchemyConnectionField (PetType .connection )
1225
+
1226
+ schema = graphene .Schema (query = Query )
1227
+
1228
+ assert "Filter" not in str (schema )
Original file line number Diff line number Diff line change @@ -513,7 +513,7 @@ def __init_subclass_with_meta__(
513
513
_meta .fields = sqla_fields
514
514
515
515
# Save Generated filter class in Meta Class
516
- if not _meta .filter_class :
516
+ if create_filters and not _meta .filter_class :
517
517
# Map graphene fields to filters
518
518
# TODO we might need to pass the ORMFields containing the SQLAlchemy models
519
519
# to the scalar filters here (to generate expressions from the model)
You can’t perform that action at this time.
0 commit comments