hasura / ra-data-hasura

react-admin data provider for Hasura GraphQL Engine
MIT License
336 stars 70 forks source link

added support for empty operator in buildGetListVariables #125

Closed ofilipowicz closed 2 years ago

ofilipowicz commented 2 years ago

I had a case where I needed a filter that will list all orders without a review. According to Hasura docs, that's how it should be done: https://hasura.io/docs/latest/queries/postgres/query-filters/#fetch-if-nested-objects-existdo-not-exist

I was unable to do so with the current conditions in buildGetListVariables.ts. I added a condition that allows {} as an operation. It generates an empty operator instead of a default _eq.

It allowed me to write a filter with source="_not#review@{}" that generates this kind of query:

query OrdersWithoutReviews {
  orders(where: {_and: [{_not: {review: {}}}]}) {
    review {
      id
    }
  }
}