hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
30.98k stars 2.75k forks source link

Support for more JSONB operators for Postgres #10138

Open vijayprasanna13 opened 5 months ago

vijayprasanna13 commented 5 months ago

Description

Currently, the documentation for JSONB column operators has support for only _contains, _contained_in, _has_key, _has_keys_any and _has_keys_all. However, in PostgreSQL, we can execute queries using operators such as >, <, =, among others, as illustrated in the example below:

select * from service_item_instances where (custom_data ->> 'screen_size')::int > 30;

The documented operators might not suffice for operations like >, <, =, and similar comparisons.

anish-pr commented 4 months ago

@vijayprasanna13 @SamirTalwar Any updates on this? whether it will come in future or cant be done?

SamirTalwar commented 4 months ago

Hey @anish-pr, thanks for pinging me.

Currently, we don't support this kind of composition over JSONB columns, and doing so would require a significant modification to our GraphQL syntax and schema. There are no plans to make changes to this in Hasura v2. We plan on providing much greater support for JSONB columns with v3, but it won't be in the first batch of functionality.

We suggest you use one of two features to accomplish this.

  1. Computed fields will allow you to transform the JSONB column so that you can work with it.
  2. Native queries let you write your own SQL and then automatically convert it into a GraphQL structure for you.

Hopefully one of those suits your needs!

anish-pr commented 2 weeks ago

@SamirTalwar @vijayprasanna13 any updates on this? when can we expect this? we have a growing need for filtering based on JSONB column values like greater than, less than, equals, etc. We use Hasura extensively for all our workflows, and sometimes because of the nature of the data, it is schemaless too. This would help us.