Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/7.x' into breaking/remove-options
Browse files Browse the repository at this point in the history
  • Loading branch information
darrellwarde committed Nov 13, 2024
2 parents dff24a8 + 56022ba commit 6b0793a
Show file tree
Hide file tree
Showing 254 changed files with 6,822 additions and 5,911 deletions.
26 changes: 26 additions & 0 deletions .changeset/fresh-pumpkins-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
"@neo4j/graphql": patch
---

Deprecate implicit `SET`:

```graphql
mutation {
updateMovies( update: { id: "2" }) {
movies {
id
}
}
}
```
in favour of the explicit `_SET` version:

```graphql
mutation {
updateMovies(update: { id_SET: "2" }) {
movies {
id
}
}
}
```
7 changes: 7 additions & 0 deletions .changeset/healthy-swans-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@neo4j/graphql": major
---

The deprecated `directed` argument has been removed, and `queryDirection` now only accepts two possible values - `DIRECTED` (default) and `UNDIRECTED`.

Additionally, the `directedArgument` setting of `excludeDeprecatedFields` has been removed as these deprecated fields have been removed.
5 changes: 5 additions & 0 deletions .changeset/mean-horses-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@neo4j/graphql": patch
---

Added `implicitSet` to the `excludeDeprecatedFields` setting, to disable generation of the deprecated mutation field without the suffix `_SET`.
4 changes: 2 additions & 2 deletions .github/workflows/reusable-codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
with:
node-version: lts/*
- name: Initialize CodeQL
uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd # v3
uses: github/codeql-action/init@4f3212b61783c3c68e8309a0f18a699764811cda # v3
with:
config-file: ./.github/codeql/codeql-config.yml
languages: javascript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd # v3
uses: github/codeql-action/analyze@4f3212b61783c3c68e8309a0f18a699764811cda # v3
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"tabWidth": 2
}
}
]
],
"trailingComma": "es5"
}
2 changes: 2 additions & 0 deletions jest.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ module.exports = {
escapeString: true,
printBasicPrototype: true,
},

prettierPath: require.resolve("prettier-2"),
};
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@tsconfig/node16": "1.0.4",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
"concurrently": "9.0.1",
"concurrently": "9.1.0",
"dotenv": "16.4.5",
"eslint": "8.57.1",
"eslint-config-prettier": "9.1.0",
Expand All @@ -41,7 +41,8 @@
"jest": "29.7.0",
"lint-staged": "15.2.10",
"neo4j-driver": "5.26.0",
"prettier": "2.8.8",
"prettier": "3.3.3",
"prettier-2": "npm:[email protected]",
"set-tz": "0.2.0",
"ts-jest": "29.2.5",
"typescript": "5.1.6"
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
"@types/is-uuid": "1.0.2",
"@types/jest": "29.5.14",
"@types/jsonwebtoken": "9.0.7",
"@types/node": "20.17.5",
"@types/node": "22.9.0",
"@types/pluralize": "0.0.33",
"@types/randomstring": "1.3.0",
"@types/semver": "7.5.8",
"@types/supertest": "6.0.2",
"@types/ws": "8.5.12",
"@types/ws": "8.5.13",
"graphql-middleware": "6.1.35",
"graphql-tag": "2.12.6",
"graphql-ws": "5.16.0",
Expand All @@ -64,7 +64,7 @@
"koa-jwt": "4.0.4",
"koa-router": "13.0.1",
"mock-jwks": "1.0.10",
"nock": "13.5.5",
"nock": "13.5.6",
"randomstring": "1.3.0",
"rimraf": "5.0.10",
"supertest": "7.0.0",
Expand Down
12 changes: 8 additions & 4 deletions packages/graphql/src/classes/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ export interface NodeConstructor extends GraphElementConstructor {
globalIdFieldIsInt?: boolean;
}

type MutableField = PrimitiveField | CustomScalarField | CustomEnumField | UnionField | TemporalField | CypherField;

type AuthableField = PrimitiveField | CustomScalarField | CustomEnumField | UnionField | TemporalField | CypherField;
export type MutableField =
| PrimitiveField
| CustomScalarField
| CustomEnumField
| UnionField
| TemporalField
| CypherField;

export type RootTypeFieldNames = {
create: string;
Expand Down Expand Up @@ -161,7 +165,7 @@ class Node extends GraphElement {

/** Fields you can apply auth allow and bind to */
// Maybe we can remove this as they may not be used anymore in the new auth system
public get authableFields(): AuthableField[] {
public get authableFields(): MutableField[] {
return [
...this.primitiveFields,
...this.scalarFields,
Expand Down
22 changes: 18 additions & 4 deletions packages/graphql/src/classes/Relationship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@
*/

import type {
PrimitiveField,
PointField,
CustomEnumField,
CypherField,
CustomResolverField,
CustomScalarField,
CypherField,
PointField,
PrimitiveField,
TemporalField,
CustomResolverField,
} from "../types";
import { GraphElement } from "./GraphElement";
import type { MutableField } from "./Node";

interface RelationshipConstructor {
name: string;
type?: string;
source: string; // temporary addition to infer the source using the schema model
target: string; // temporary addition to infer the target using the schema model
relationshipFieldName: string; // temporary addition to infer the fieldName using the schema model
description?: string;
properties?: string;
cypherFields?: CypherField[];
Expand All @@ -48,6 +50,7 @@ class Relationship extends GraphElement {
public properties?: string;
public source: string;
public target: string;
public relationshipFieldName: string;

constructor(input: RelationshipConstructor) {
super({
Expand All @@ -65,6 +68,17 @@ class Relationship extends GraphElement {
this.properties = input.properties;
this.source = input.source;
this.target = input.target;
this.relationshipFieldName = input.relationshipFieldName;
}
// Fields you can set in a create or update mutation
public get mutableFields(): MutableField[] {
return [
...this.temporalFields,
...this.enumFields,
...this.scalarFields, // these are just custom scalars
...this.primitiveFields, // these are instead built-in scalars
...this.pointFields,
];
}
}

Expand Down
4 changes: 0 additions & 4 deletions packages/graphql/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ export const LOGICAL_OPERATORS = ["AND", "OR", "NOT"] as const;
export const AGGREGATION_COMPARISON_OPERATORS = ["EQUAL", "GT", "GTE", "LT", "LTE"] as const;

export enum RelationshipQueryDirectionOption {
DEFAULT_DIRECTED = "DEFAULT_DIRECTED",
DEFAULT_UNDIRECTED = "DEFAULT_UNDIRECTED",
DIRECTED_ONLY = "DIRECTED_ONLY",
UNDIRECTED_ONLY = "UNDIRECTED_ONLY",
DIRECTED = "DIRECTED",
UNDIRECTED = "UNDIRECTED",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,6 @@ import { RelationshipQueryDirectionOption } from "../../../../constants";
export const RelationshipQueryDirectionEnum = new GraphQLEnumType({
name: "RelationshipQueryDirection",
values: {
[RelationshipQueryDirectionOption.DEFAULT_DIRECTED]: {
deprecationReason:
"DEFAULT_DIRECTED is deprecated without alternative and it will be removed in future versions, this is following the deprecation of the generated `directed` argument",
},
[RelationshipQueryDirectionOption.DEFAULT_UNDIRECTED]: {
deprecationReason:
"DEFAULT_UNDIRECTED is deprecated without alternative and it will be removed in future versions, this is following the deprecation of the generated `directed` argument",
},
[RelationshipQueryDirectionOption.DIRECTED_ONLY]: {
deprecationReason: "DIRECTED_ONLY is deprecated, please use DIRECTED.",
},
[RelationshipQueryDirectionOption.UNDIRECTED_ONLY]: {
deprecationReason: "UNDIRECTED_ONLY is deprecated, please use UNDIRECTED.",
},
[RelationshipQueryDirectionOption.DIRECTED]: {},
[RelationshipQueryDirectionOption.UNDIRECTED]: {},
},
Expand Down
4 changes: 2 additions & 2 deletions packages/graphql/src/graphql/directives/relationship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export const relationshipDirective = new GraphQLDirective({
},
queryDirection: {
type: RelationshipQueryDirectionEnum,
defaultValue: RelationshipQueryDirectionOption.DEFAULT_DIRECTED,
description: "Valid and default directions for this relationship.",
defaultValue: RelationshipQueryDirectionOption.DIRECTED,
description: "Directions to query this relationship.",
},
direction: {
type: new GraphQLNonNull(RelationshipDirectionEnum),
Expand Down
4 changes: 2 additions & 2 deletions packages/graphql/src/schema-model/generate-model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ describe("Relationship", () => {
expect(accounts).toBeDefined();
expect(accounts?.type).toBe("HAS_ACCOUNT");
expect(accounts?.direction).toBe("OUT");
expect(accounts?.queryDirection).toBe("DEFAULT_DIRECTED");
expect(accounts?.queryDirection).toBe("DIRECTED");
expect(accounts?.nestedOperations).toEqual([
"CREATE",
"UPDATE",
Expand Down Expand Up @@ -427,7 +427,7 @@ describe("Relationship", () => {
expect(actors).toBeDefined();
expect(actors?.type).toBe("STARED_IN");
expect(actors?.direction).toBe("OUT");
expect(actors?.queryDirection).toBe("DEFAULT_DIRECTED");
expect(actors?.queryDirection).toBe("DIRECTED");
expect(actors?.nestedOperations).toEqual([
"CREATE",
"UPDATE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import type { Attribute } from "../attribute/Attribute";
import type { Entity } from "../entity/Entity";

export type RelationshipDirection = "IN" | "OUT";
// "DIRECTED" | "UNDIRECTED";
export type QueryDirection = keyof typeof RelationshipQueryDirectionOption;
// "DEFAULT_DIRECTED" | "DEFAULT_UNDIRECTED" | "DIRECTED_ONLY" | "UNDIRECTED_ONLY" | "DIRECTED" | "UNDIRECTED";
export type NestedOperation = keyof typeof RelationshipNestedOperationsOption;
// "CREATE" | "UPDATE" | "DELETE" | "CONNECT" | "DISCONNECT" | "CONNECT_OR_CREATE";
export type NestedOperation = keyof typeof RelationshipNestedOperationsOption;

export class Relationship {
public readonly name: string; // name of the relationship field, e.g. friends
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe("RelationshipAdapter", () => {
direction: "OUT",
isList: Boolean(false),
attributes: [accountAlias],
queryDirection: "DEFAULT_DIRECTED",
queryDirection: "DIRECTED",
nestedOperations: ["CREATE", "UPDATE", "DELETE", "CONNECT", "DISCONNECT", "CONNECT_OR_CREATE"],
aggregate: false,
description: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ export class RelationshipAdapter {
* @param directed the direction asked during the query, for instance "friends(directed: true)"
* @returns the direction to use in the CypherBuilder
**/
public getCypherDirection(directed?: boolean): "left" | "right" | "undirected" {
if (directed === false || this.queryDirection === "UNDIRECTED_ONLY" || this.queryDirection === "UNDIRECTED") {
public getCypherDirection(): "left" | "right" | "undirected" {
if (this.queryDirection === "UNDIRECTED") {
return "undirected";
}
return this.cypherDirectionFromRelDirection();
Expand Down
7 changes: 7 additions & 0 deletions packages/graphql/src/schema/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ export const DEPRECATE_DIRECTED_ARGUMENT = {
reason: "The directed argument is deprecated, and the direction of the field will be configured in the GraphQL server",
},
};

export const DEPRECATE_IMPLICIT_SET = {
name: DEPRECATED,
args: {
reason: "Please use the explicit _SET field",
},
};
1 change: 1 addition & 0 deletions packages/graphql/src/schema/create-connection-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export function createConnectionFields({
source: relationship.source.name,
target: relationship.target.name,
properties: relationship instanceof RelationshipAdapter ? relationship.propertiesTypeName : undefined,
relationshipFieldName: relationship.name,
...(relFields
? {
temporalFields: relFields.temporalFields,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { RelationshipAdapter } from "../../schema-model/relationship/model-adapt
import { RelationshipDeclarationAdapter } from "../../schema-model/relationship/model-adapters/RelationshipDeclarationAdapter";
import type { Neo4jFeaturesSettings } from "../../types";
import { FieldAggregationComposer } from "../aggregations/field-aggregation-composer";
import { addDirectedArgument } from "../directed-argument";
import {
augmentObjectOrInterfaceTypeWithConnectionField,
augmentObjectOrInterfaceTypeWithRelationshipField,
Expand Down Expand Up @@ -264,13 +263,11 @@ export function createRelationshipFields({
where: relationshipTarget.operations.whereInputTypeName,
};

const aggregationFieldsArgs = addDirectedArgument(aggregationFieldsBaseArgs, relationshipAdapter, features);

if (relationshipAdapter.aggregate) {
composeNode.addFields({
[relationshipAdapter.operations.aggregateTypeName]: {
type: aggregationTypeObject,
args: aggregationFieldsArgs,
args: aggregationFieldsBaseArgs,
directives: deprecatedDirectives,
},
});
Expand Down Expand Up @@ -320,18 +317,12 @@ function createRelationshipFieldsForTarget({
relationshipAdapter,
userDefinedFieldDirectives,
subgraph,
features,
composer,
})
);

composeNode.addFields(
augmentObjectOrInterfaceTypeWithConnectionField(
relationshipAdapter,
userDefinedFieldDirectives,
composer,
features
)
augmentObjectOrInterfaceTypeWithConnectionField(relationshipAdapter, userDefinedFieldDirectives, composer)
);

withRelationInputType({
Expand Down
Loading

0 comments on commit 6b0793a

Please sign in to comment.