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

Allow sorting by computed fields

Open vivekkannavenus opened this issue 4 years ago • 15 comments

It would be so great if Hasura supports computed field in order by Eg:

{
    show(order_by: {
       show_distance(args: {lat: 77.7843636, long: 9.4664509}): asc
    }) {
       ...ShowDetails
    }
}

Function created for Computed field show_distance

ST_Distance(
       ST_Transform(location::Geometry, 3857),
       ST_Transform(ST_SetSRID(ST_MakePoint(lat, long), 4326), 3857)
)

vivekkannavenus avatar Apr 09 '20 18:04 vivekkannavenus

Related to https://github.com/hasura/graphql-engine/issues/3772

tirumaraiselvan avatar Apr 11 '20 09:04 tirumaraiselvan

@tirumaraiselvan Hi Selvan, We're waiting for this feature for a long time. May I know, when developers can access this feature.

Sorting based on distance is one of the main functionality in our app. So, I would like to see the ticket with a closed tag.

vivekkannavenus avatar Aug 21 '20 07:08 vivekkannavenus

@vivekkannavenus Hi. Unfortunately, the ETA for this is still not clear at the moment because of backlog. I can probably suggest workarounds using Views/Custom functions if you can share your schema and computed field definitions.

tirumaraiselvan avatar Aug 21 '20 08:08 tirumaraiselvan

Our team would really appreciate this! Our use case is sorting content by a computed score column and filtering results by followed sources. Serving this content feed is the main functionality of our product, so first class support for ordering by computed fields would be great.

crieggalder avatar Sep 08 '20 07:09 crieggalder

would very much appreciate this being implemented!

robandrose avatar Sep 25 '20 21:09 robandrose

+1 Would be amazing to have this.

FickleLife avatar Nov 18 '20 01:11 FickleLife

@tirumaraiselvan Any update on this? Would be really helpful to reduce extra views and functions.

amnaveenriaz avatar Jun 16 '21 01:06 amnaveenriaz

Much needed..

manuFL avatar Jun 23 '21 14:06 manuFL

Hi, any updates?

mikejackowski avatar Jun 25 '21 12:06 mikejackowski

+1, any updates on the feature?

For anyone interested, a viable workaround seems to be creating a view with all of the original table's columns plus the desired calculated field.

lorenzosignoretti avatar Jun 28 '21 09:06 lorenzosignoretti

Is there any chance this gets bumped from "p/longterm" to something closer to a more immediate development/release?

mikejackowski avatar Jun 28 '21 12:06 mikejackowski

+1, Any update on this feature?

akhilrajvc avatar Mar 02 '22 04:03 akhilrajvc

+1 - any updates on this feature?

austin-coffman avatar Apr 27 '22 17:04 austin-coffman

any updates on sorting by computed_field with args? It's been a while now

mikejackowski avatar Sep 06 '22 09:09 mikejackowski

@mikejackowski this feature request is not currently scheduled. I believe it's also not strictly necessary, since it is possible to sort the results of tracked custom functions, even if it's not currently possible to sort by computed fields. This is illustrated in this GitHub repository and sub-directory:

https://github.com/dventimihasura/hasura-projects/tree/master/computed-fields-1

dventimihasura avatar Sep 10 '22 18:09 dventimihasura