Skip to content

Commit

Permalink
Remove implicit filter fields (#5801)
Browse files Browse the repository at this point in the history
* Remove unused deprecation

* Remove implicit filter fields

* Create red-cows-shop.md

* Keep placeholder file for deprecations

* Add subscriptions filtering function for EQ
  • Loading branch information
darrellwarde authored Nov 18, 2024
1 parent 99cb9aa commit 95ce8bb
Show file tree
Hide file tree
Showing 118 changed files with 323 additions and 2,512 deletions.
23 changes: 23 additions & 0 deletions .changeset/red-cows-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
"@neo4j/graphql": major
---

Implicit filtering fields have been removed, please use the explicit versions:

```graphql
# Old syntax
{
movies(where: { title: "The Matrix" }) {
title
}
}

# New syntax
{
movies(where: { title_EQ: "The Matrix" }) {
title
}
}
```

The `implicitEqualFilters` option of `excludeDeprecatedFields` has been removed.
16 changes: 1 addition & 15 deletions packages/graphql/src/schema/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,4 @@
* limitations under the License.
*/

import { DEPRECATED } from "../constants";

export const DEPRECATE_IMPLICIT_EQUAL_FILTERS = {
name: DEPRECATED,
args: {
reason: "Please use the explicit _EQ version",
},
};

export const DEPRECATE_DIRECTED_ARGUMENT = {
name: DEPRECATED,
args: {
reason: "The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server",
},
};
// TODO: Add constant deprecations here
12 changes: 2 additions & 10 deletions packages/graphql/src/schema/generation/aggregate-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ import type { RelationshipAdapter } from "../../schema-model/relationship/model-
import { RelationshipDeclarationAdapter } from "../../schema-model/relationship/model-adapters/RelationshipDeclarationAdapter";
import type { Neo4jFeaturesSettings } from "../../types";
import type { AggregationTypesMapper } from "../aggregations/aggregation-types-mapper";
import { DEPRECATE_IMPLICIT_EQUAL_FILTERS } from "../constants";
import { numericalResolver } from "../resolvers/field/numerical";
import { graphqlDirectivesToCompose } from "../to-compose";
import { shouldAddDeprecatedFields } from "./utils";

export function withAggregateSelectionType({
entityAdapter,
Expand Down Expand Up @@ -111,12 +109,6 @@ export function withAggregateInputType({
},
});

if (shouldAddDeprecatedFields(features, "implicitEqualFilters")) {
aggregateWhereInput.addFields({
count: { type: GraphQLInt, directives: [DEPRECATE_IMPLICIT_EQUAL_FILTERS] },
});
}

aggregateWhereInput.addFields({
AND: aggregateWhereInput.NonNull.List,
OR: aggregateWhereInput.NonNull.List,
Expand Down Expand Up @@ -251,8 +243,8 @@ function addAggregationFieldsByType(
const averageType = attribute.typeHelper.isBigInt()
? "BigInt"
: attribute.typeHelper.isDuration()
? "Duration"
: GraphQLFloat;
? "Duration"
: GraphQLFloat;
fields[`${attribute.name}_AVERAGE_${operator}`] = { type: averageType, directives: deprecatedDirectives };
}
return fields;
Expand Down
8 changes: 0 additions & 8 deletions packages/graphql/src/schema/get-where-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import { DEPRECATED } from "../constants";
import type { AttributeAdapter } from "../schema-model/attribute/model-adapters/AttributeAdapter";
import { ConcreteEntityAdapter } from "../schema-model/entity/model-adapters/ConcreteEntityAdapter";
import type { Neo4jFeaturesSettings } from "../types";
import { DEPRECATE_IMPLICIT_EQUAL_FILTERS } from "./constants";
import { shouldAddDeprecatedFields } from "./generation/utils";
import { graphqlDirectivesToCompose } from "./to-compose";

// TODO: refactoring needed!
Expand Down Expand Up @@ -81,12 +79,6 @@ export function getWhereFieldsForAttributes({
}
}

if (shouldAddDeprecatedFields(features, "implicitEqualFilters")) {
result[field.name] = {
type: field.getInputTypeNames().where.pretty,
directives: deprecatedDirectives.length ? deprecatedDirectives : [DEPRECATE_IMPLICIT_EQUAL_FILTERS],
};
}
result[`${field.name}_EQ`] = {
type: field.getInputTypeNames().where.pretty,
directives: deprecatedDirectives,
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/src/schema/resolvers/query/global-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function globalNodeResolver({ entities }: { entities: ConcreteEntityAdapt
const resolveTree = {
name: entityAdapter.plural,
alias: "node",
args: { where: { [field]: id } },
args: { where: { [`${field}_EQ`]: id } },
fieldsByTypeName,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type { AttributeAdapter } from "../../../../../schema-model/attribute/mod
type ComparatorFn<T> = (received: T, filtered: T, fieldMeta?: AttributeAdapter | undefined) => boolean;

const operatorCheckMap = {
EQ: (received: string, filtered: string) => received == filtered,
NOT: (received: string, filtered: string) => received !== filtered,
LT: (received: number | string, filtered: number) => {
const parsed = typeof received === "string" ? BigInt(received) : received;
Expand Down
Loading

0 comments on commit 95ce8bb

Please sign in to comment.