diff --git a/graphene_sqlalchemy/tests/test_filters.py b/graphene_sqlalchemy/tests/test_filters.py index 4acf89a..82c4c23 100644 --- a/graphene_sqlalchemy/tests/test_filters.py +++ b/graphene_sqlalchemy/tests/test_filters.py @@ -1199,3 +1199,30 @@ async def test_additional_filters(session): schema = graphene.Schema(query=Query) result = await schema.execute_async(query, context_value={"session": session}) assert_and_raise_result(result, expected) + + +@pytest.mark.asyncio +async def test_do_not_create_filters(): + class WithoutFilters(SQLAlchemyObjectType): + class Meta: + abstract = True + + @classmethod + def __init_subclass_with_meta__(cls, _meta=None, **options): + super().__init_subclass_with_meta__( + _meta=_meta, create_filters=False, **options + ) + + class PetType(WithoutFilters): + class Meta: + model = Pet + name = "Pet" + interfaces = (relay.Node,) + connection_class = Connection + + class Query(graphene.ObjectType): + pets = SQLAlchemyConnectionField(PetType.connection) + + schema = graphene.Schema(query=Query) + + assert "Filter" not in str(schema) diff --git a/graphene_sqlalchemy/types.py b/graphene_sqlalchemy/types.py index 0695751..894ebfd 100644 --- a/graphene_sqlalchemy/types.py +++ b/graphene_sqlalchemy/types.py @@ -513,7 +513,7 @@ def __init_subclass_with_meta__( _meta.fields = sqla_fields # Save Generated filter class in Meta Class - if not _meta.filter_class: + if create_filters and not _meta.filter_class: # Map graphene fields to filters # TODO we might need to pass the ORMFields containing the SQLAlchemy models # to the scalar filters here (to generate expressions from the model)