graphql-engine icon indicating copy to clipboard operation
graphql-engine copied to clipboard

[Feature Request] Add a new type to timestamptz_comparison_exp

Open leoalves opened this issue 6 years ago • 3 comments

From time to time, I find myself having to add interval to some of my queries. Since this is not supported by Hasura, I need to create a view or a function. And I am not able to use it within permissions.

I think it would be great if this could be supported, by default, in Hasura.

My suggestion is to add a _interval type to the timestamptz_comparison_exp

Something like

query {
  users (where: {
    created_at: {
      _interval {
        _gte: {
          date1: "now()"
          operator: "-"
          date2: "10 days"
        }
      }
    }
  }) {
    name
  }  
} 

This would generate the following SQL:

SELECT name FROM users WHERE created_at >= now() - interval '10 days';

Thanks

leoalves avatar May 14 '19 01:05 leoalves

This is closely related to #2699, though this solution (adding an _interval type) is much easier to explain than the salesforce-style alternative in the other ticket

thecodedrift avatar Dec 01 '21 02:12 thecodedrift

I prefer this solution is closer to the Hasura "philosophy" in my opinion...

And probably easier to implement, I would even say that it could be simpler.

query {
  users (where: {
    created_at: {
       _gte:  "now() - 10 days"
    }
  }) {
    name
  }  

wieseljonas avatar Apr 03 '23 10:04 wieseljonas