Steams / ra-data-hasura-graphql

React-admin data provider for Hasura GraphQL endpoints
MIT License
211 stars 33 forks source link

How do I pass filters other than the built-in _eq, _ilike, etc? #49

Open polymeris opened 4 years ago

polymeris commented 4 years ago

It's unclear to me from the docs (and I am also not very knowledgeable about JS/react-admin).

I'd like to filter a List by a date range, i.e. something like {_and: {_gte: "..."}, {_lt: "..."}}.

Thanks!

akamit21 commented 4 years ago

For the fetching list, I am using a query something like this:

const fetchData = () => {
    dataProvider
      .getList('table_name', {
        pagination: {},
        sort: { field: 'id', order: 'ASC' },
        filter: {
          column_name: { _gt: date, _lt: date },
        },
      })
      .then(({ data: list }) => {
        // success side effects go here
      })
      .catch(() => {
        // failure side effects go here
      });
  };