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

[Relay] support aggregate

Open ippo012 opened this issue 3 years ago • 25 comments

I've tried the Relay API, but I can't find a way to aggregate it in the Relay API. It would be great if xxx_aggregate was generated in query_root or if a field like total_count was added in xxx_connection.

For example:

query MyQuery {
  user_aggregate {
    aggregate {
      count
    }
  }
}

or

query MyQuery {
  user_connection {
    + total_count
    edges {
      node {
        id
        name
      }
    }
  }
}

Thank you!

ippo012 avatar Aug 26 '20 09:08 ippo012

Any solution or update here?

Vbubblery avatar Sep 05 '20 03:09 Vbubblery

Was also expecting this to be in relay. You can get aggregate relations, but odd that you can't get the actual aggregates of the root tables themselves.

hellsan631 avatar Sep 11 '20 23:09 hellsan631

What's weird is that the types for x_aggregate do seem to be generated, but it doesn't include a distinct_on or where parameter, and is also not exposed by default on the query root, so it doesn't seem usable.

Can someone from Hasura comment about whether this is something they intend to support?

UlyssesInvictus avatar Oct 07 '20 21:10 UlyssesInvictus

As another clarification, it seems that array_relationship is supported for aggregate purposes, and leads to x, x_aggregate, and x_connection fields all being added ... except at the root query level. I guess this is what the other users up-thread were referring to, but I only just now understood this clarification after digging through the graph that was generated.

UlyssesInvictus avatar Oct 08 '20 03:10 UlyssesInvictus

any update on this core feature?

mutasemhidmi avatar Jan 25 '21 07:01 mutasemhidmi

Having the same issue. Any updates on weather this will be supported soon?

Albosonic avatar Feb 17 '21 21:02 Albosonic

FWIW, my work around here is to make call to the standard hasura endpoint where the aggregate values are available at the top level. Then Make my relay api queries subsequently.

Albosonic avatar Feb 18 '21 21:02 Albosonic

Anything new? Relay's totalCount is really important, we need to display the number of rows/pages the user can paginate.

korengrip avatar Mar 11 '21 14:03 korengrip

i don't think it's the timing to use relay in hasura right now.

I already reverted what I did before (use hasura relay to do the pagination), right now i just use normal hausra schema to do the pagination. And Currently, Hasura’s Relay schema doesn’t expose remote schemas or actions. So, some complex logic is hard to handle with hasura relay.

Vbubblery avatar Mar 11 '21 14:03 Vbubblery

@Vbubblery Hasura schema pagination has some serious drawbacks. limit/offset might cause data duplication on high-frequent updated tables, and implementing cursor pagination on an incremental field is too dirty. I don't like it.

korengrip avatar Mar 11 '21 14:03 korengrip

any update?

ikigroup avatar Nov 09 '21 13:11 ikigroup

It's unfortunate there's no discussion from the Hasura team in over a year on this. GraphQL + Relay + React is the stack many enterprises large and small are going to be building with.

KayakinKoder avatar Dec 22 '21 12:12 KayakinKoder

Any update?

matiasf9 avatar Jan 14 '22 01:01 matiasf9

anyone?

matheus1lva avatar Feb 01 '22 13:02 matheus1lva

Any update on this issue?

cbear99 avatar Mar 07 '22 21:03 cbear99

I've since migrated off this project/team, but we were required to completely abandon Hasura due to this, as Relay's opinionated schema standard was far more important to us than using Hasura, which had plentiful competitors.

Hopefully a team member sees this and can respond, but I can't recommend the tool at this point in time to anyone.

UlyssesInvictus avatar Mar 07 '22 21:03 UlyssesInvictus

We also have the same need, it's important for us to return paginated results, and having the total count regardless of the page size is key.

apecollector avatar Mar 30 '22 16:03 apecollector

Up. I need this feature as well

minhdtb avatar Sep 22 '22 06:09 minhdtb

I've since migrated off this project/team, but we were required to completely abandon Hasura due to this, as Relay's opinionated schema standard was far more important to us than using Hasura, which had plentiful competitors.

Hopefully a team member sees this and can respond, but I can't recommend the tool at this point in time to anyone.

What tool did you ending up using? I'm also giving up on Hasura based on their poor Relay support.

matiasf9 avatar Jan 09 '23 05:01 matiasf9

Sorry, it's been even longer by now so I don't remember at this point in time; but I remember it was just one of the other major competitor libraries, nothing to esoteric.

UlyssesInvictus avatar Jan 10 '23 18:01 UlyssesInvictus

What is the current recommended way to aggregate at the root table level ?

niranjan94 avatar May 03 '23 08:05 niranjan94

Thanks everyone for your comments and patience on this issue. We have been closely listening into all the feedback and requests from the community, and have been working on a re-imagined, re-architectured Hasura, that tackles many of these from ground up. We are pleased to announce that we are launching V3-Alpha of Hasura (Data Delivery Network) on our next Community call on Nov 30. Relay is an important focus in V3 and will be a first class citizen. While aggregations will not be available in the Alpha version yet, it's in our near term roadmap. We would request to join this community call to learn more about Hasura V3. We will continue to update this issue as soon we have clear timeline for this support.

manasag avatar Nov 23 '23 15:11 manasag

Relay is an important focus in V3

The word "relay" doesn't appear even a single time in the v3 docs. I remember being in a community call with Tanmai more than 2 years ago when he stated something very similar e.g. "relay is top of our mind/a first class citizen" and in those 2 years, there have been precisely zero relay features built.

We'd love to see relay features, but to anyone reading this, I wouldn't hold your breath.

KayakinKoder avatar Dec 01 '23 21:12 KayakinKoder

@KayakinKoder While more Relay features are underway, you can start using Relay's Global ID and node fields as specified here: https://hasura.io/docs/3.0/data-domain-modeling/global-id/

We will add more docs for Relay in GraphQL section of the docs very soon as well.

tirumaraiselvan avatar Dec 02 '23 01:12 tirumaraiselvan

@tirumaraiselvan I don't understand how I can utilize Global ID to get aggregate queries like the entire count of the entries.

I'm currently resorting on REST endpoints generated from "vanilla" GraphQL aggregate queries.

Zeta611 avatar Apr 03 '24 07:04 Zeta611