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

[Feature Branch] Aggregation 7 #6011

Merged
merged 136 commits into from
Mar 10, 2025
Merged

[Feature Branch] Aggregation 7 #6011

merged 136 commits into from
Mar 10, 2025

Conversation

angrykoala
Copy link
Member

Description

This is a feature branch of the breaking changes to aggregations in version 7.

This branch also contains the changes from #5945

angrykoala and others added 30 commits January 17, 2025 09:24
Top Level aggregations in connections
angrykoala and others added 22 commits February 27, 2025 12:42
…ngesets

Include deprecations for aggregation filters and changesets for the new aggregation filters
…ion-filters

Make the new aggregation filters compliant with `@filterable` and `@relationship` directives.
Co-authored-by: MacondoExpress <simone.gammicchia@neotechnology.com>
@angrykoala angrykoala marked this pull request as ready for review March 10, 2025 14:40
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] <jest/no-disabled-tests> reported by reviewdog 🐶
Disabled test

test.skip("aggregation", async () => {
const query = `
{
productionsConnection(where: { OR: [ { typename: [${Movie.name}, ${Series.name}] } { typename: [${Cartoon.name}] } ] }) {
aggregate {
count {
nodes
}
}
}
}
`;
const queryResult = await testHelper.executeGraphQL(query);
expect(queryResult.errors).toBeUndefined();
expect(queryResult.data).toEqual({
productionsConnection: {
count: {
nodes: 3,
},
},
});
});

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] <jest/no-disabled-tests> reported by reviewdog 🐶
Disabled test

test.skip("nested aggregation", async () => {
const query = `
{
${Actor.plural} {
actedInConnection(where: { NOT: { typename: [${Movie.name}, ${Series.name}] } }) {
aggegate {
count {
nodes
}
}
}
}
}
`;
const queryResult = await testHelper.executeGraphQL(query);
expect(queryResult.errors).toBeUndefined();
expect(queryResult.data).toEqual({
[Actor.plural]: expect.arrayContaining([
{
actedInConnection: {
count: {
nodes: 1,
},
},
},
]),
});
});

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] <jest/no-disabled-tests> reported by reviewdog 🐶
Disabled test

test.skip("default arguments should disable aggregation", async () => {
const typeDefs = /* GraphQL */ `
type Actor @node {
username: String!
movies: [Movie!]! @relationship(type: "ACTED_IN", direction: OUT)
}
type Movie @subscription @node {
title: String @filterable
actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN)
}
`;
const neoSchema = new Neo4jGraphQL({
typeDefs,
features: {
subscriptions: new TestCDCEngine(),
excludeDeprecatedFields: {
aggregationFiltersOutsideConnection: true,
},
},
});
const schema = await neoSchema.getSchema();
const movieWhereType = schema.getType("MovieWhere") as GraphQLInputObjectType;
expect(movieWhereType).toBeDefined();
const movieWhereFields = movieWhereType.getFields();
expect(movieWhereFields.title).toBeDefined();
expect(movieWhereFields.releaseDate).toBeDefined();
const movieSubscriptionWhereType = schema.getType("MovieSubscriptionWhere") as GraphQLInputObjectType;
expect(movieSubscriptionWhereType).toBeDefined();
const movieSubscriptionWhereFields = movieSubscriptionWhereType.getFields();
const subscriptionTitle_EQ = movieSubscriptionWhereFields["title_EQ"];
const subscriptionTitle_IN = movieSubscriptionWhereFields["title_IN"];
const subscriptionTitle_CONTAINS = movieSubscriptionWhereFields["title_CONTAINS"];
const subscriptionTitle_STARTS_WITH = movieSubscriptionWhereFields["title_STARTS_WITH"];
const subscriptionTitle_ENDS_WITH = movieSubscriptionWhereFields["title_ENDS_WITH"];
const subscriptionTitleFilters = [
subscriptionTitle_EQ,
subscriptionTitle_IN,
subscriptionTitle_CONTAINS,
subscriptionTitle_STARTS_WITH,
subscriptionTitle_ENDS_WITH,
];
for (const scalarFilter of subscriptionTitleFilters) {
expect(scalarFilter).toBeDefined();
}
const aggregationWhereInput = schema.getType(
"ActorMoviesNodeAggregationWhereInput"
) as GraphQLInputObjectType;
expect(aggregationWhereInput).toBeUndefined();
});

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] <jest/no-disabled-tests> reported by reviewdog 🐶
Disabled test

test.skip("enable value and aggregation filters", async () => {
const typeDefs = gql`
type Actor @node {
username: String!
password: String!
movies: [Movie!]! @relationship(type: "ACTED_IN", direction: OUT)
}
type Movie @subscription @node {
title: String @filterable(byValue: true, byAggregate: true)
actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN)
}
`;
const neoSchema = new Neo4jGraphQL({
typeDefs,
features: {
subscriptions: new TestCDCEngine(),
},
});
const schema = await neoSchema.getSchema();
const movieWhereType = schema.getType("MovieWhere") as GraphQLInputObjectType;
expect(movieWhereType).toBeDefined();
const movieWhereFields = movieWhereType.getFields();
const title_EQ = movieWhereFields["title_EQ"];
const title_IN = movieWhereFields["title_IN"];
const title_CONTAINS = movieWhereFields["title_CONTAINS"];
const title_STARTS_WITH = movieWhereFields["title_STARTS_WITH"];
const title_ENDS_WITH = movieWhereFields["title_ENDS_WITH"];
const titleFilters = [title_EQ, title_IN, title_CONTAINS, title_STARTS_WITH, title_ENDS_WITH];
for (const scalarFilter of titleFilters) {
expect(scalarFilter).toBeDefined();
}
const movieSubscriptionWhereType = schema.getType("MovieSubscriptionWhere") as GraphQLInputObjectType;
expect(movieSubscriptionWhereType).toBeDefined();
const movieSubscriptionWhereFields = movieSubscriptionWhereType.getFields();
const subscriptionTitle_EQ = movieSubscriptionWhereFields["title_EQ"];
const subscriptionTitle_IN = movieSubscriptionWhereFields["title_IN"];
const subscriptionTitle_CONTAINS = movieSubscriptionWhereFields["title_CONTAINS"];
const subscriptionTitle_STARTS_WITH = movieSubscriptionWhereFields["title_STARTS_WITH"];
const subscriptionTitle_ENDS_WITH = movieSubscriptionWhereFields["title_ENDS_WITH"];
const subscriptionTitleFilters = [
subscriptionTitle_EQ,
subscriptionTitle_IN,
subscriptionTitle_CONTAINS,
subscriptionTitle_STARTS_WITH,
subscriptionTitle_ENDS_WITH,
];
for (const scalarFilter of subscriptionTitleFilters) {
expect(scalarFilter).toBeDefined();
}
const aggregationWhereInput = schema.getType(
"ActorMoviesNodeAggregationWhereInput"
) as GraphQLInputObjectType;
expect(aggregationWhereInput).toBeDefined();
const aggregationWhereInputFields = aggregationWhereInput.getFields();
const title_AGG = aggregationWhereInputFields["title"];
expect(title_AGG).toBeUndefined();
});

@angrykoala angrykoala merged commit 68a0bc4 into 7.x Mar 10, 2025
35 checks passed
@angrykoala angrykoala deleted the aggregation-7 branch March 10, 2025 14:50
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.

2 participants