Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save danstarns/166fbfbca5e99bbb5d29c48c143eeec9 to your computer and use it in GitHub Desktop.

Select an option

Save danstarns/166fbfbca5e99bbb5d29c48c143eeec9 to your computer and use it in GitHub Desktop.
aggregation-queries-hasura-vs-neo4j-graphql

Aggregation Queries Hasura vs Neo4j GraphQL

Comparing the queries here.

Fetch aggregated data of an object

Hasura

query {
    articles_aggregate {
        aggregate {
            count
            sum {
                rating
            }
            avg {
                rating
            }
            max {
                rating
            }
        }
        nodes {
            id
            title
            rating
        }
    }
}

Neo4j GraphQL

query {
    articlesAggregate {
        count
        rating {
            average
            max
            sum ## Missing
        }
    }
    articles {
        id
        title
        rating
    }
}

Fetch aggregated data on nested objects

Hasura

query {
    authors(where: { id: { _eq: 1 } }) {
        id
        name
        articles_aggregate {
            aggregate {
                count
                avg {
                    rating
                }
                max {
                    rating
                }
            }
            nodes {
                id
                title
                rating
            }
        }
    }
}

Neo4j GraphQL

query {
    authors(where: { id: 1 }) {
        id
        name
        articlesAggregate {
            count
            rating {
                average
                max
            }
        }
        articles {
            id
            title
            rating
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment