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

Top Level aggregations in connections #5944

Merged
merged 10 commits into from
Jan 23, 2025
Merged

Conversation

angrykoala
Copy link
Member

Description

Add top level aggregations inside connection operations:

query {
    moviesConnection {
        aggregate {
            node {
                count
                id {
                    longest 
                }
            }
        }
    }
}

Copy link

changeset-bot bot commented Jan 21, 2025

🦋 Changeset detected

Latest commit: 5d36415

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@neo4j/graphql Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@angrykoala angrykoala force-pushed the aggregation-connections branch from 60e7337 to ef2d979 Compare January 21, 2025 17:02
@angrykoala angrykoala changed the base branch from dev to aggregation-6 January 21, 2025 17:33
@angrykoala angrykoala marked this pull request as ready for review January 22, 2025 10:45
@angrykoala angrykoala marked this pull request as draft January 22, 2025 10:46
@angrykoala angrykoala marked this pull request as ready for review January 22, 2025 16:37
Copy link
Contributor

@MacondoExpress MacondoExpress left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -138,4 +159,38 @@ export class CompositeConnectionReadOperation extends Operation {
return [...nodeFields, ...edgeFields];
});
}

// NOTE: duplicate from ConnectionReadOperation
private transpileAggregation(context: QueryASTContext): {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it will be right approach the proposal I'm saying but:
Can we expose this method from the aggregationField and avoid duplicity between the CompositeConnectionReadOperation and the ConnectionReadOperation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, I don't think that is the best option. Sure, the code is the same, but it is more coincidental than anything, as transpilation for compositeConnection doesn't necessarily have to be the same, and I'm hesitant to couple the nested element of the tree. I'd rather have this duplicate code than break the encapsulation on those

await testHelper.executeCypher(
`
CREATE (:${typeMovie} {testString: "${testString}", id: "1", title: "1", imdbRating: 1, createdAt: datetime("${minDate.toISOString()}")})
CREATE (:${typeMovie} {testString: "${testString}", id: "22", title: "22", imdbRating: 2, createdAt: datetime()})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if these tests were already made, in my opinion, it will cover more cases if some entries are filtered out by the testString filter!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you said, those cases are already covered. And these tests are based on the existing ones, Improving tests on aggregations is a bit out of scope for this, already quite big, PR. But I'll keep this in mind as we do need to improve these tests once the aggregations work is complete

@angrykoala angrykoala merged commit 2cb4148 into aggregation-6 Jan 23, 2025
2 checks passed
@angrykoala angrykoala deleted the aggregation-connections branch January 23, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants