postgraphile-plugin-connection-filter icon indicating copy to clipboard operation
postgraphile-plugin-connection-filter copied to clipboard

Support passing arguments to functions as filters

Open scottgonzalez opened this issue 3 years ago • 2 comments

Computed columns support functions and will expose the new field as a filter as long as there are no required arguments. Providing defaults for the arguments will allow the function to be used as a filter, but it is not currently possible to provide a value to use in place of the defaults. Would you be willing to support a new property, alongside the operators, which would take an object containing the arguments to pass to the function?

Given the example in #110, this would allow a filter like:

filter: {
  distance_from: {
    lessThan: 300
    args: {
      origin_lat: 51.111
      origin_lng: -7.123123
    }
  }
}

scottgonzalez avatar Apr 22 '21 14:04 scottgonzalez

+1 This would help us as well quite a bit. It would eliminate the need for running several plugins (currently we might need: https://github.com/RoadRunnerEngineering/postgraphile-plugin-custom-filter to accommodate this).

ltamrazov avatar Apr 22 '21 14:04 ltamrazov

:+1: I can see that being useful. I don't have the bandwidth to tackle this right now, but would definitely welcome a PR.

mattbretl avatar Aug 02 '21 05:08 mattbretl