graphile-contrib / postgraphile-plugin-connection-filter

Filtering on PostGraphile connections
MIT License
286 stars 32 forks source link

Postgraphile V5 - Filtering by nested relations not working when filter value is `undefiend` #208

Open scottravio opened 8 months ago

scottravio commented 8 months ago

Version: 3.0.0-beta.2

When filtering by a related table field, the plugin works when the filter value is defined. When the filter value is undefined the filter plugin seems to filter out rows where the related table row is null.

For example given a query like:

query Query($departmentId: UUID) {
   users(
      filter : {
         jobTitleToDepartment: {
             department: { id: { equalTo: $departmentId }}
         }
      }
   ) {
       nodes {
           id
       }
    }
}

This works as long as the department relation exists. If querying for a user with a job title that does not have a department, no rows are returned when the $departmentId variable is undefined. Expected behaviour is to ignore the filter with the filter value is undefined

The jobTitleToDepartment relation is a virtual constraint created with the @foreignKey smart tag