Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support skipping count aggregate on hasura #120

Merged
merged 3 commits into from
Jul 27, 2022

Conversation

mohammad-bolt
Copy link
Contributor

issue: #117

current hasura graphql provider always make an aggregate count call

tota: table(
    order_by: $order_by
    where: $where
  ) {
    aggregate {
      count
      __typename
    }

which is very expensive on most RDMS like postgres.

this PR introduces a very simple workaround. when caller providers
aggregateFieldName(resource) = NO_COUNT we simply skip count call and provide partial pagination instead.

This is a NO-OP unless caller provide custom aggregateFiledName function.

TEST

called sample app with and without

aggregateFieldName: (_) => "NO_COUNT"

and verified the behavior.

@arjunyel arjunyel merged commit 8503ba7 into hasura:master Jul 27, 2022
@arjunyel
Copy link
Contributor

@mohammad-bolt thank you so much! When you have a moment could please you add this to the readme?

@mohammad-bolt mohammad-bolt deleted the skip-aggregate-count branch July 27, 2022 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants