graphql-engine
graphql-engine copied to clipboard
[Feature Request] Add a new type to timestamptz_comparison_exp
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
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
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
}