Skip to content

Record skipping/filtering #235

Closed
Closed
@rrva

Description

@rrva

I want to implement a filter that can be applied to any field, which does not need to be explicitly defined on each field in the schema.

Either as a directive that can be passed in the query, or as a filter parameter, which is automatically added to each field.

I am looking for:

  • Some way to hook into the execution of the default data fetchers, for example MethodFieldResolverDataFetcher to evaluate my filter before the field is fetched, and if the filter condition is false, return null. The filter expression is to be fetched either from a query directive or a field parameter
  • If I go down the route of adding a filter parameter to each field, it would be useful to have some way to transform the schema and add a filter: String parameter to all fields programmatically
type Query {
  characters(): [Character]!
}

type Character {
  name: String!
  favoriteFood: Food!
}

type Food {
   name: String!
   cookingTimeMinutes: Int!
}

I could write a query like

{ 
    characters {
        name(filter: "Lando Calrissian")
        favoriteFood
    }
}

or

{ 
    characters {
        name @filter(expr: "Lando Calrissian")
     }
}

and also express the filter on any field level

{ 
    characters {
        name
        favoriteFood {
             name(filter: "Meatballs")
             cookingTimeMinutes
         }
     }
}

and the execution would only result in those Character values where the filter expression returns true
without expressing @filter or filter: on each field in the schema definition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions