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
31.11k stars 2.77k forks source link

Add support for sorting by json path in V3 #10018

Open manasag opened 10 months ago

manasag commented 10 months ago

This request was originally created here #2592 . This issue is to track this feature request in Hasura V3. Details:

The ability to sort the query results by a path of a JSON columns For example, for a table like

CREATE TABLE products (
  id serial NOT NULL PRIMARY KEY,
  translated_name jsonb NULL
);

I would like to have the ability to do something like

query productsSortedByName {
    products(order_by: {translated_name: {path: "en", how: asc_nulls_last}}) {
       id
       name: translated_name (path: "en")
   }
}
CapCap commented 5 months ago

This would be great as the whole point of json is dynamic data- your solution using native queries is no different than using a view in terms of end user experience, and as such is not a solution to the original problem.

manasag commented 4 months ago

Good news is that in V3 architecture, we have recently added support for nested filtering and ordering. While we currently are focusing on implementing these concepts for Mongodb as a priority; it paves the way to do the same with jsonb values with Postgres.