Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions graphene_sqlalchemy/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).lower()
2 changes: 1 addition & 1 deletion graphene_sqlalchemy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down