Filtered Index for Graphql @Index

I want to implement soft deletions with an is deleted field. Is it possible to create a pre-filtered index that I can pass to graphql @index in order to automatically filter out non active documents?

Something like the following:

type Student {
  name: String! @unique
  isActive: Boolean!
}

type Query {
  allStudents: [Student!] @index(name: "all_active_users")

I understand that this can be done with a custom resolver but was hoping that I could do some type of autogenerated route

If you have an Index called all_active_users already that is expecting an input value for your field data.isActive then Fauna probably already autogenerated what you need and you should be able to add this to your Query type.

type Query {
  all_active_users(isActive: Boolean! = true): [Student!]
}

I never was able to find a way to set a default value in the Index itself. I am sure there is a way to do it but instead I just define a default value in my schema file like in the above. This works for me.

Hope this helps! :upside_down_face:

1 Like

That is perfect. Thanks!