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

backport typename filter in v6 #5934

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/fluffy-schools-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"@neo4j/graphql": minor
---

Introduced the `typename` filter that superseded the `typename_IN` filter.
As part of the change, the flag `typename_IN` has been added to the `excludeDeprecatedFields` setting.

```js
const neoSchema = new Neo4jGraphQL({
typeDefs,
features: { excludeDeprecatedFields: { typename_IN: true } },
});
```
7 changes: 7 additions & 0 deletions packages/graphql/src/schema/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,10 @@ export const DEPRECATE_OVERWRITE = {
reason: "The overwrite argument is deprecated and will be removed",
},
};

export const DEPRECATE_TYPENAME_IN = {
name: DEPRECATED,
args: {
reason: "The typename_IN filter is deprecated, please use the typename filter instead",
},
};
10 changes: 8 additions & 2 deletions packages/graphql/src/schema/generation/where-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { UnionEntityAdapter } from "../../schema-model/entity/model-adapters/Uni
import { RelationshipAdapter } from "../../schema-model/relationship/model-adapters/RelationshipAdapter";
import type { RelationshipDeclarationAdapter } from "../../schema-model/relationship/model-adapters/RelationshipDeclarationAdapter";
import type { Neo4jFeaturesSettings } from "../../types";
import { DEPRECATE_IMPLICIT_EQUAL_FILTERS } from "../constants";
import { DEPRECATE_IMPLICIT_EQUAL_FILTERS, DEPRECATE_TYPENAME_IN } from "../constants";
import { getWhereFieldsForAttributes } from "../get-where-fields";
import { withAggregateInputType } from "./aggregate-types";
import {
Expand Down Expand Up @@ -143,7 +143,13 @@ export function withWhereInputType({
name: entityAdapter.operations.implementationEnumTypename,
values: enumValues,
});
whereInputType.addFields({ typename_IN: { type: interfaceImplementation.NonNull.List } });
if (shouldAddDeprecatedFields(features, "typename_IN")) {
whereInputType.addFields({
typename_IN: { type: interfaceImplementation.NonNull.List, directives: [DEPRECATE_TYPENAME_IN] },
});
}

whereInputType.addFields({ typename: { type: interfaceImplementation.NonNull.List } });
}
}
return whereInputType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ export class FilterFactory {
filters: nestedFilters,
});
}
if (key === "typename_IN") {
if (key === "typename_IN" || key === "typename") {
const acceptedEntities = entity.concreteEntities.filter((concreteEntity) => {
return valueAsArray.some((typenameFilterValue) => typenameFilterValue === concreteEntity.name);
});
Expand Down
1 change: 1 addition & 0 deletions packages/graphql/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ export type Neo4jFeaturesSettings = {
deprecatedOptionsArgument?: boolean;
directedArgument?: boolean;
connectOrCreate?: boolean;
typename_IN?: boolean;
};
vector?: Neo4jVectorSettings;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe("typename_IN", () => {
test("top-level", async () => {
const query = `
{
productions(where: { OR: [{ AND: [{ title_EQ: "The Matrix" }, { typename_IN: [${Movie.name}] }] }, { typename_IN: [${Series.name}] }]}) {
productions(where: { OR: [{ AND: [{ title_EQ: "The Matrix" }, { typename: [${Movie.name}] }] }, { typename: [${Series.name}] }]}) {
__typename
title
}
Expand Down Expand Up @@ -116,8 +116,8 @@ describe("typename_IN", () => {
{
${Actor.plural} {
actedIn(where: { OR: [
{ AND: [{ title_EQ: "The Matrix" }, { typename_IN: [${Movie.name}] }] }
{ typename_IN: [${Series.name}] }
{ AND: [{ title_EQ: "The Matrix" }, { typename: [${Movie.name}] }] }
{ typename: [${Series.name}] }
] }) {
__typename
title
Expand Down Expand Up @@ -149,7 +149,7 @@ describe("typename_IN", () => {
test("aggregation", async () => {
const query = `
{
productionsAggregate(where: { OR: [ { typename_IN: [${Movie.name}, ${Series.name}] } { typename_IN: [${Cartoon.name}] } ] }) {
productionsAggregate(where: { OR: [ { typename: [${Movie.name}, ${Series.name}] } { typename: [${Cartoon.name}] } ] }) {
count
}
}
Expand All @@ -168,7 +168,7 @@ describe("typename_IN", () => {
const query = `
{
${Actor.plural} {
actedInAggregate(where: { NOT: { typename_IN: [${Movie.name}, ${Series.name}] } }) {
actedInAggregate(where: { NOT: { typename: [${Movie.name}, ${Series.name}] } }) {
count
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/graphql/tests/schema/comments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,8 @@ describe("Comments", () => {
title_EQ: String
title_IN: [String!]
title_STARTS_WITH: String
typename_IN: [ProductionImplementation!]
typename: [ProductionImplementation!]
typename_IN: [ProductionImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type ProductionsConnection {
Expand Down
6 changes: 4 additions & 2 deletions packages/graphql/tests/schema/connections/interfaces.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ describe("Connection with interfaces", () => {
movies: ProductionWhere
moviesAggregate: CreatureMoviesAggregateInput
moviesConnection: CreatureMoviesConnectionWhere
typename_IN: [CreatureImplementation!]
typename: [CreatureImplementation!]
typename_IN: [CreatureImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type CreaturesConnection {
Expand Down Expand Up @@ -804,7 +805,8 @@ describe("Connection with interfaces", () => {
id_EQ: ID
id_IN: [ID]
id_STARTS_WITH: ID
typename_IN: [ProductionImplementation!]
typename: [ProductionImplementation!]
typename_IN: [ProductionImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type ProductionsConnection {
Expand Down
9 changes: 6 additions & 3 deletions packages/graphql/tests/schema/directive-preserve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,8 @@ describe("Directive-preserve", () => {
title_EQ: String
title_IN: [String!]
title_STARTS_WITH: String
typename_IN: [ProductionImplementation!]
typename: [ProductionImplementation!]
typename_IN: [ProductionImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type ProductionsConnection {
Expand Down Expand Up @@ -2517,7 +2518,8 @@ describe("Directive-preserve", () => {
title_EQ: String
title_IN: [String!]
title_STARTS_WITH: String
typename_IN: [ProductionImplementation!]
typename: [ProductionImplementation!]
typename_IN: [ProductionImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type ProductionsConnection {
Expand Down Expand Up @@ -3454,7 +3456,8 @@ describe("Directive-preserve", () => {
title_EQ: String
title_IN: [String!]
title_STARTS_WITH: String
typename_IN: [ProductionImplementation!]
typename: [ProductionImplementation!]
typename_IN: [ProductionImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type ProductionsConnection {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ describe("@customResolver directive", () => {
customResolver_EQ: String
customResolver_IN: [String]
customResolver_STARTS_WITH: String
typename_IN: [UserInterfaceImplementation!]
typename: [UserInterfaceImplementation!]
typename_IN: [UserInterfaceImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type UserInterfacesConnection {
Expand Down
3 changes: 2 additions & 1 deletion packages/graphql/tests/schema/directives/cypher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,8 @@ describe("Cypher", () => {
AND: [ProductionWhere!]
NOT: ProductionWhere
OR: [ProductionWhere!]
typename_IN: [ProductionImplementation!]
typename: [ProductionImplementation!]
typename_IN: [ProductionImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type ProductionsConnection {
Expand Down
3 changes: 2 additions & 1 deletion packages/graphql/tests/schema/directives/default.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ describe("@default directive", () => {
toBeOverridden_EQ: String
toBeOverridden_IN: [String!]
toBeOverridden_STARTS_WITH: String
typename_IN: [UserInterfaceImplementation!]
typename: [UserInterfaceImplementation!]
typename_IN: [UserInterfaceImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type UserInterfacesConnection {
Expand Down
9 changes: 6 additions & 3 deletions packages/graphql/tests/schema/directives/filterable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5891,7 +5891,8 @@ describe("@filterable directive", () => {
AND: [PersonWhere!]
NOT: PersonWhere
OR: [PersonWhere!]
typename_IN: [PersonImplementation!]
typename: [PersonImplementation!]
typename_IN: [PersonImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
username: String @deprecated(reason: \\"Please use the explicit _EQ version\\")
username_CONTAINS: String
username_ENDS_WITH: String
Expand Down Expand Up @@ -6587,7 +6588,8 @@ describe("@filterable directive", () => {
AND: [PersonWhere!]
NOT: PersonWhere
OR: [PersonWhere!]
typename_IN: [PersonImplementation!]
typename: [PersonImplementation!]
typename_IN: [PersonImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
username: String @deprecated(reason: \\"Please use the explicit _EQ version\\")
username_CONTAINS: String
username_ENDS_WITH: String
Expand Down Expand Up @@ -7248,7 +7250,8 @@ describe("@filterable directive", () => {
AND: [PersonWhere!]
NOT: PersonWhere
OR: [PersonWhere!]
typename_IN: [PersonImplementation!]
typename: [PersonImplementation!]
typename_IN: [PersonImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
username: String @deprecated(reason: \\"Please use the explicit _EQ version\\")
username_CONTAINS: String
username_ENDS_WITH: String
Expand Down
6 changes: 4 additions & 2 deletions packages/graphql/tests/schema/directives/private.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ describe("@private directive", () => {
id_EQ: ID
id_IN: [ID]
id_STARTS_WITH: ID
typename_IN: [UserInterfaceImplementation!]
typename: [UserInterfaceImplementation!]
typename_IN: [UserInterfaceImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type UserInterfacesConnection {
Expand Down Expand Up @@ -393,7 +394,8 @@ describe("@private directive", () => {
id_EQ: ID
id_IN: [ID]
id_STARTS_WITH: ID
typename_IN: [UserInterfaceImplementation!]
typename: [UserInterfaceImplementation!]
typename_IN: [UserInterfaceImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type UserInterfacesConnection {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,8 @@ describe("@relationship directive, aggregate argument", () => {
password_EQ: String
password_IN: [String!]
password_STARTS_WITH: String
typename_IN: [PersonImplementation!]
typename: [PersonImplementation!]
typename_IN: [PersonImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
username: String @deprecated(reason: \\"Please use the explicit _EQ version\\")
username_CONTAINS: String
username_ENDS_WITH: String
Expand Down Expand Up @@ -1849,7 +1850,8 @@ describe("@relationship directive, aggregate argument", () => {
password_EQ: String
password_IN: [String!]
password_STARTS_WITH: String
typename_IN: [PersonImplementation!]
typename: [PersonImplementation!]
typename_IN: [PersonImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
username: String @deprecated(reason: \\"Please use the explicit _EQ version\\")
username_CONTAINS: String
username_ENDS_WITH: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8350,7 +8350,8 @@ describe("Relationship nested operations", () => {
name_EQ: String
name_IN: [String]
name_STARTS_WITH: String
typename_IN: [PersonImplementation!]
typename: [PersonImplementation!]
typename_IN: [PersonImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type Query {
Expand Down Expand Up @@ -8837,7 +8838,8 @@ describe("Relationship nested operations", () => {
name_EQ: String
name_IN: [String]
name_STARTS_WITH: String
typename_IN: [PersonImplementation!]
typename: [PersonImplementation!]
typename_IN: [PersonImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type Query {
Expand Down Expand Up @@ -9323,7 +9325,8 @@ describe("Relationship nested operations", () => {
name_EQ: String
name_IN: [String]
name_STARTS_WITH: String
typename_IN: [PersonImplementation!]
typename: [PersonImplementation!]
typename_IN: [PersonImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type Query {
Expand Down Expand Up @@ -9805,7 +9808,8 @@ describe("Relationship nested operations", () => {
name_EQ: String
name_IN: [String]
name_STARTS_WITH: String
typename_IN: [PersonImplementation!]
typename: [PersonImplementation!]
typename_IN: [PersonImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type Query {
Expand Down Expand Up @@ -10286,7 +10290,8 @@ describe("Relationship nested operations", () => {
name_EQ: String
name_IN: [String]
name_STARTS_WITH: String
typename_IN: [PersonImplementation!]
typename: [PersonImplementation!]
typename_IN: [PersonImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type Query {
Expand Down Expand Up @@ -10763,7 +10768,8 @@ describe("Relationship nested operations", () => {
name_EQ: String
name_IN: [String]
name_STARTS_WITH: String
typename_IN: [PersonImplementation!]
typename: [PersonImplementation!]
typename_IN: [PersonImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type Query {
Expand Down Expand Up @@ -11388,7 +11394,8 @@ describe("Relationship nested operations", () => {
name_EQ: String
name_IN: [String]
name_STARTS_WITH: String
typename_IN: [PersonImplementation!]
typename: [PersonImplementation!]
typename_IN: [PersonImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type Query {
Expand Down Expand Up @@ -11989,7 +11996,8 @@ describe("Relationship nested operations", () => {
name_EQ: String
name_IN: [String]
name_STARTS_WITH: String
typename_IN: [PersonImplementation!]
typename: [PersonImplementation!]
typename_IN: [PersonImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type Query {
Expand Down
6 changes: 4 additions & 2 deletions packages/graphql/tests/schema/directives/selectable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2851,7 +2851,8 @@ describe("@selectable", () => {
title_EQ: String
title_IN: [String!]
title_STARTS_WITH: String
typename_IN: [ProductionImplementation!]
typename: [ProductionImplementation!]
typename_IN: [ProductionImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type ProductionsConnection {
Expand Down Expand Up @@ -3411,7 +3412,8 @@ describe("@selectable", () => {
title_EQ: String
title_IN: [String!]
title_STARTS_WITH: String
typename_IN: [ProductionImplementation!]
typename: [ProductionImplementation!]
typename_IN: [ProductionImplementation!] @deprecated(reason: \\"The typename_IN filter is deprecated, please use the typename filter instead\\")
}

type ProductionsConnection {
Expand Down
Loading
Loading