Skip to content

Commit 932bfa7

Browse files
authored
Merge pull request #5999 from neo4j/nested-aggregations-deprecation
Deprecate field aggregate fields in favor of nested connection aggregate fields
2 parents 1540f5a + 47f915e commit 932bfa7

File tree

98 files changed

+811
-791
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+811
-791
lines changed

.changeset/sixty-steaks-reflect.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@neo4j/graphql": patch
3+
---
4+
5+
Deprecate aggrgation fields (e.g `actedInAggregate`) in favor of the field `aggregate` inside the connection (e.g `actedInConnection -> aggregate`)

packages/graphql/src/schema/constants.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import { DEPRECATED } from "../constants";
2121
import type { ConcreteEntityAdapter } from "../schema-model/entity/model-adapters/ConcreteEntityAdapter";
2222
import type { InterfaceEntityAdapter } from "../schema-model/entity/model-adapters/InterfaceEntityAdapter";
23+
import type { RelationshipAdapter } from "../schema-model/relationship/model-adapters/RelationshipAdapter";
24+
import type { RelationshipDeclarationAdapter } from "../schema-model/relationship/model-adapters/RelationshipDeclarationAdapter";
2325

2426
export const DEPRECATE_IMPLICIT_EQUAL_FILTERS = {
2527
name: DEPRECATED,
@@ -81,7 +83,16 @@ export function DEPRECATE_AGGREGATION(entity: ConcreteEntityAdapter | InterfaceE
8183
return {
8284
name: DEPRECATED,
8385
args: {
84-
reason: `Please use the explicit the field "aggregate" inside "${entity.operations.rootTypeFieldNames.connection}"`,
86+
reason: `Please use the explicit field "aggregate" inside "${entity.operations.rootTypeFieldNames.connection}" instead`,
87+
},
88+
};
89+
}
90+
91+
export function DEPRECATE_NESTED_AGGREGATION(relationship: RelationshipAdapter | RelationshipDeclarationAdapter) {
92+
return {
93+
name: DEPRECATED,
94+
args: {
95+
reason: `Please use field "aggregate" inside "${relationship.operations.connectionFieldName}" instead`,
8596
},
8697
};
8798
}

packages/graphql/src/schema/create-relationship-fields/create-relationship-fields.ts

+14-9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { RelationshipAdapter } from "../../schema-model/relationship/model-adapt
2929
import { RelationshipDeclarationAdapter } from "../../schema-model/relationship/model-adapters/RelationshipDeclarationAdapter";
3030
import type { Neo4jFeaturesSettings } from "../../types";
3131
import { FieldAggregationComposer } from "../aggregations/field-aggregation-composer";
32+
import { DEPRECATE_NESTED_AGGREGATION } from "../constants";
3233
import { addDirectedArgument } from "../directed-argument";
3334
import {
3435
augmentObjectOrInterfaceTypeWithConnectionField,
@@ -48,6 +49,7 @@ import { getRelationshipPropertiesTypeDescription, withObjectType } from "../gen
4849
import { withRelationInputType } from "../generation/relation-input";
4950
import { withSortInputType } from "../generation/sort-and-options-input";
5051
import { augmentUpdateInputTypeWithUpdateFieldInput, withUpdateInputType } from "../generation/update-input";
52+
import { shouldAddDeprecatedFields } from "../generation/utils";
5153
import { withSourceWhereInputType, withWhereInputType } from "../generation/where-input";
5254
import { graphqlDirectivesToCompose } from "../to-compose";
5355

@@ -270,15 +272,18 @@ export function createRelationshipFields({
270272
const aggregationFieldsArgs = addDirectedArgument(aggregationFieldsBaseArgs, relationshipAdapter, features);
271273

272274
if (relationshipAdapter.aggregate) {
273-
// OLD AGGREGATIONS
274-
// TODO: deprecate
275-
composeNode.addFields({
276-
[relationshipAdapter.operations.aggregateTypeName]: {
277-
type: aggregationTypeObject,
278-
args: aggregationFieldsArgs,
279-
directives: deprecatedDirectives,
280-
},
281-
});
275+
if (shouldAddDeprecatedFields(features, "deprecatedAggregateOperations")) {
276+
composeNode.addFields({
277+
[relationshipAdapter.operations.aggregateTypeName]: {
278+
type: aggregationTypeObject,
279+
args: aggregationFieldsArgs,
280+
directives:
281+
deprecatedDirectives.length > 0
282+
? deprecatedDirectives
283+
: [DEPRECATE_NESTED_AGGREGATION(relationshipAdapter)],
284+
},
285+
});
286+
}
282287
}
283288
}
284289

packages/graphql/tests/schema/aggregations.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ describe("Aggregations", () => {
362362
363363
type Query {
364364
movies(limit: Int, offset: Int, options: MovieOptions @deprecated(reason: \\"Query options argument is deprecated, please use pagination arguments like limit, offset and sort instead.\\"), sort: [MovieSort!], where: MovieWhere): [Movie!]!
365-
moviesAggregate(where: MovieWhere): MovieAggregateSelection! @deprecated(reason: \\"Please use the explicit the field \\\\\\"aggregate\\\\\\" inside \\\\\\"moviesConnection\\\\\\"\\")
365+
moviesAggregate(where: MovieWhere): MovieAggregateSelection! @deprecated(reason: \\"Please use the explicit field \\\\\\"aggregate\\\\\\" inside \\\\\\"moviesConnection\\\\\\" instead\\")
366366
moviesConnection(after: String, first: Int, sort: [MovieSort!], where: MovieWhere): MoviesConnection!
367367
}
368368
@@ -851,7 +851,7 @@ describe("Aggregations", () => {
851851
852852
type Post {
853853
likes(directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), limit: Int, offset: Int, options: UserOptions @deprecated(reason: \\"Query options argument is deprecated, please use pagination arguments like limit, offset and sort instead.\\"), sort: [UserSort!], where: UserWhere): [User!]!
854-
likesAggregate(directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), where: UserWhere): PostUserLikesAggregationSelection
854+
likesAggregate(directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), where: UserWhere): PostUserLikesAggregationSelection @deprecated(reason: \\"Please use field \\\\\\"aggregate\\\\\\" inside \\\\\\"likesConnection\\\\\\" instead\\")
855855
likesConnection(after: String, directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), first: Int, sort: [PostLikesConnectionSort!], where: PostLikesConnectionWhere): PostLikesConnection!
856856
someID: ID
857857
title: String
@@ -1224,10 +1224,10 @@ describe("Aggregations", () => {
12241224
12251225
type Query {
12261226
posts(limit: Int, offset: Int, options: PostOptions @deprecated(reason: \\"Query options argument is deprecated, please use pagination arguments like limit, offset and sort instead.\\"), sort: [PostSort!], where: PostWhere): [Post!]!
1227-
postsAggregate(where: PostWhere): PostAggregateSelection! @deprecated(reason: \\"Please use the explicit the field \\\\\\"aggregate\\\\\\" inside \\\\\\"postsConnection\\\\\\"\\")
1227+
postsAggregate(where: PostWhere): PostAggregateSelection! @deprecated(reason: \\"Please use the explicit field \\\\\\"aggregate\\\\\\" inside \\\\\\"postsConnection\\\\\\" instead\\")
12281228
postsConnection(after: String, first: Int, sort: [PostSort!], where: PostWhere): PostsConnection!
12291229
users(limit: Int, offset: Int, options: UserOptions @deprecated(reason: \\"Query options argument is deprecated, please use pagination arguments like limit, offset and sort instead.\\"), sort: [UserSort!], where: UserWhere): [User!]!
1230-
usersAggregate(where: UserWhere): UserAggregateSelection! @deprecated(reason: \\"Please use the explicit the field \\\\\\"aggregate\\\\\\" inside \\\\\\"usersConnection\\\\\\"\\")
1230+
usersAggregate(where: UserWhere): UserAggregateSelection! @deprecated(reason: \\"Please use the explicit field \\\\\\"aggregate\\\\\\" inside \\\\\\"usersConnection\\\\\\" instead\\")
12311231
usersConnection(after: String, first: Int, sort: [UserSort!], where: UserWhere): UsersConnection!
12321232
}
12331233

packages/graphql/tests/schema/array-methods.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe("Arrays Methods", () => {
8585
8686
type Actor {
8787
actedIn(directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), limit: Int, offset: Int, options: MovieOptions @deprecated(reason: \\"Query options argument is deprecated, please use pagination arguments like limit, offset and sort instead.\\"), sort: [MovieSort!], where: MovieWhere): [Movie!]!
88-
actedInAggregate(directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), where: MovieWhere): ActorMovieActedInAggregationSelection
88+
actedInAggregate(directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), where: MovieWhere): ActorMovieActedInAggregationSelection @deprecated(reason: \\"Please use field \\\\\\"aggregate\\\\\\" inside \\\\\\"actedInConnection\\\\\\" instead\\")
8989
actedInConnection(after: String, directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), first: Int, sort: [ActorActedInConnectionSort!], where: ActorActedInConnectionWhere): ActorActedInConnection!
9090
name: String
9191
}
@@ -365,7 +365,7 @@ describe("Arrays Methods", () => {
365365
366366
type Movie {
367367
actors(directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), limit: Int, offset: Int, options: ActorOptions @deprecated(reason: \\"Query options argument is deprecated, please use pagination arguments like limit, offset and sort instead.\\"), sort: [ActorSort!], where: ActorWhere): [Actor!]!
368-
actorsAggregate(directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), where: ActorWhere): MovieActorActorsAggregationSelection
368+
actorsAggregate(directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), where: ActorWhere): MovieActorActorsAggregationSelection @deprecated(reason: \\"Please use field \\\\\\"aggregate\\\\\\" inside \\\\\\"actorsConnection\\\\\\" instead\\")
369369
actorsConnection(after: String, directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), first: Int, sort: [MovieActorsConnectionSort!], where: MovieActorsConnectionWhere): MovieActorsConnection!
370370
averageRating: Float!
371371
id: ID!
@@ -635,10 +635,10 @@ describe("Arrays Methods", () => {
635635
636636
type Query {
637637
actors(limit: Int, offset: Int, options: ActorOptions @deprecated(reason: \\"Query options argument is deprecated, please use pagination arguments like limit, offset and sort instead.\\"), sort: [ActorSort!], where: ActorWhere): [Actor!]!
638-
actorsAggregate(where: ActorWhere): ActorAggregateSelection! @deprecated(reason: \\"Please use the explicit the field \\\\\\"aggregate\\\\\\" inside \\\\\\"actorsConnection\\\\\\"\\")
638+
actorsAggregate(where: ActorWhere): ActorAggregateSelection! @deprecated(reason: \\"Please use the explicit field \\\\\\"aggregate\\\\\\" inside \\\\\\"actorsConnection\\\\\\" instead\\")
639639
actorsConnection(after: String, first: Int, sort: [ActorSort!], where: ActorWhere): ActorsConnection!
640640
movies(limit: Int, offset: Int, options: MovieOptions @deprecated(reason: \\"Query options argument is deprecated, please use pagination arguments like limit, offset and sort instead.\\"), sort: [MovieSort!], where: MovieWhere): [Movie!]!
641-
moviesAggregate(where: MovieWhere): MovieAggregateSelection! @deprecated(reason: \\"Please use the explicit the field \\\\\\"aggregate\\\\\\" inside \\\\\\"moviesConnection\\\\\\"\\")
641+
moviesAggregate(where: MovieWhere): MovieAggregateSelection! @deprecated(reason: \\"Please use the explicit field \\\\\\"aggregate\\\\\\" inside \\\\\\"moviesConnection\\\\\\" instead\\")
642642
moviesConnection(after: String, first: Int, sort: [MovieSort!], where: MovieWhere): MoviesConnection!
643643
}
644644

packages/graphql/tests/schema/arrays.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ describe("Arrays", () => {
183183
184184
type Query {
185185
movies(limit: Int, offset: Int, options: MovieOptions @deprecated(reason: \\"Query options argument is deprecated, please use pagination arguments like limit, offset and sort instead.\\"), sort: [MovieSort!], where: MovieWhere): [Movie!]!
186-
moviesAggregate(where: MovieWhere): MovieAggregateSelection! @deprecated(reason: \\"Please use the explicit the field \\\\\\"aggregate\\\\\\" inside \\\\\\"moviesConnection\\\\\\"\\")
186+
moviesAggregate(where: MovieWhere): MovieAggregateSelection! @deprecated(reason: \\"Please use the explicit field \\\\\\"aggregate\\\\\\" inside \\\\\\"moviesConnection\\\\\\" instead\\")
187187
moviesConnection(after: String, first: Int, sort: [MovieSort!], where: MovieWhere): MoviesConnection!
188188
}
189189

packages/graphql/tests/schema/authorization.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ describe("Authorization", () => {
9797
9898
type Post {
9999
author(directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), limit: Int, offset: Int, options: UserOptions @deprecated(reason: \\"Query options argument is deprecated, please use pagination arguments like limit, offset and sort instead.\\"), sort: [UserSort!], where: UserWhere): User!
100-
authorAggregate(directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), where: UserWhere): PostUserAuthorAggregationSelection
100+
authorAggregate(directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), where: UserWhere): PostUserAuthorAggregationSelection @deprecated(reason: \\"Please use field \\\\\\"aggregate\\\\\\" inside \\\\\\"authorConnection\\\\\\" instead\\")
101101
authorConnection(after: String, directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), first: Int, sort: [PostAuthorConnectionSort!], where: PostAuthorConnectionWhere): PostAuthorConnection!
102102
id: ID!
103103
name: String!
@@ -307,10 +307,10 @@ describe("Authorization", () => {
307307
308308
type Query {
309309
posts(limit: Int, offset: Int, options: PostOptions @deprecated(reason: \\"Query options argument is deprecated, please use pagination arguments like limit, offset and sort instead.\\"), sort: [PostSort!], where: PostWhere): [Post!]!
310-
postsAggregate(where: PostWhere): PostAggregateSelection! @deprecated(reason: \\"Please use the explicit the field \\\\\\"aggregate\\\\\\" inside \\\\\\"postsConnection\\\\\\"\\")
310+
postsAggregate(where: PostWhere): PostAggregateSelection! @deprecated(reason: \\"Please use the explicit field \\\\\\"aggregate\\\\\\" inside \\\\\\"postsConnection\\\\\\" instead\\")
311311
postsConnection(after: String, first: Int, sort: [PostSort!], where: PostWhere): PostsConnection!
312312
users(limit: Int, offset: Int, options: UserOptions @deprecated(reason: \\"Query options argument is deprecated, please use pagination arguments like limit, offset and sort instead.\\"), sort: [UserSort!], where: UserWhere): [User!]!
313-
usersAggregate(where: UserWhere): UserAggregateSelection! @deprecated(reason: \\"Please use the explicit the field \\\\\\"aggregate\\\\\\" inside \\\\\\"usersConnection\\\\\\"\\")
313+
usersAggregate(where: UserWhere): UserAggregateSelection! @deprecated(reason: \\"Please use the explicit field \\\\\\"aggregate\\\\\\" inside \\\\\\"usersConnection\\\\\\" instead\\")
314314
usersConnection(after: String, first: Int, sort: [UserSort!], where: UserWhere): UsersConnection!
315315
}
316316
@@ -351,7 +351,7 @@ describe("Authorization", () => {
351351
id: ID!
352352
name: String!
353353
posts(directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), limit: Int, offset: Int, options: UserOptions @deprecated(reason: \\"Query options argument is deprecated, please use pagination arguments like limit, offset and sort instead.\\"), sort: [UserSort!], where: UserWhere): [User!]!
354-
postsAggregate(directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), where: UserWhere): UserUserPostsAggregationSelection
354+
postsAggregate(directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), where: UserWhere): UserUserPostsAggregationSelection @deprecated(reason: \\"Please use field \\\\\\"aggregate\\\\\\" inside \\\\\\"postsConnection\\\\\\" instead\\")
355355
postsConnection(after: String, directed: Boolean = true @deprecated(reason: \\"The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server\\"), first: Int, sort: [UserPostsConnectionSort!], where: UserPostsConnectionWhere): UserPostsConnection!
356356
}
357357

0 commit comments

Comments
 (0)