It is often useful to have a default filter on an entity in the Admin UI. In some cases you might want to show only records that are active
, or you might have a soft-delete type of use case where you want to default to showing only entities that are not marked as deleted.
To do this, use the @AdminUISettings()
decorator and pass the defaultFilter
option. Here’s code from the database example that defaults the Admin UI to only showing users that have not been marked as deleted
:
@AdminUISettings<User>({
defaultFilter: {
deleted: false,
},
})
@ObjectType('User')
export class User extends GraphQLEntity<OrmUser> {
// ...
}
Can I Force a Filter?
This is a default filter that users can still change. If you want to force a filter for the backend, you are probably interested in Security, in particular the sections on Role Based Access Control, with which you can implement row level security filters. This lets you express filters like “Users can only view data from their own company”, or “Standard users cannot view configuration information” etc.
If you want to force a filter on the Admin UI only, there is not currently a way to do that, but we’d be keen to hear more about your use case. Open an issue and let us know how you’d like it to work.