graphene-sqlalchemy
graphene-sqlalchemy copied to clipboard
How to exclude or specifically include fields from having filters auto created
Is there a way we can explicitly list all the fields we want filters created for? Like maybe in the Meta of the sqlalchemy object type?
Have you got how to do that?
@adiberk @andmaster-one if you look in the docstring for ORMField you'll see a param for enabling/disabling filter creation. Modifying an example usage from the same docstring:
class MyModel(Base):
id = Column(Integer(), primary_key=True)
name = Column(String)
class MyType(SQLAlchemyObjectType):
class Meta:
model = MyModel
id = ORMField(create_filter=False) # disable filtering for this field
name = ORMField(create_filter=True) # True is default behavior, but we can make it explicit
You can also change the default behavior using the create_filter param on the Meta class