Skip to content

Commit

Permalink
Merge pull request #5757 from neo4j/remove-connect-or-create
Browse files Browse the repository at this point in the history
Remove connect or create
  • Loading branch information
angrykoala authored Nov 7, 2024
2 parents 43ca46a + 51d03fe commit 21ab3d6
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 586 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export type UpdateMutationArgumentNames = {
create: string;
update: string;
delete: string;
connectOrCreate: string;
where: string;
};

Expand Down Expand Up @@ -82,10 +81,6 @@ export class ImplementingEntityOperations<T extends InterfaceEntityAdapter | Con
return `${this.entityAdapter.name}UniqueWhere`;
}

public get connectOrCreateWhereInputTypeName(): string {
return `${this.entityAdapter.name}ConnectOrCreateWhere`;
}

public get connectWhereInputTypeName(): string {
return `${this.entityAdapter.name}ConnectWhere`;
}
Expand Down Expand Up @@ -118,10 +113,6 @@ export class ImplementingEntityOperations<T extends InterfaceEntityAdapter | Con
return `${this.entityAdapter.name}ConnectInput`;
}

public get connectOrCreateInputTypeName(): string {
return `${this.entityAdapter.name}ConnectOrCreateInput`;
}

public get disconnectInputTypeName(): string {
return `${this.entityAdapter.name}DisconnectInput`;
}
Expand Down Expand Up @@ -198,7 +189,6 @@ export class ImplementingEntityOperations<T extends InterfaceEntityAdapter | Con
create: this.relationInputTypeName,
update: this.updateInputTypeName,
delete: this.deleteInputTypeName,
connectOrCreate: this.connectOrCreateInputTypeName,
where: this.whereInputTypeName,
};
}
Expand All @@ -208,10 +198,4 @@ export class ImplementingEntityOperations<T extends InterfaceEntityAdapter | Con
input: `[${this.createInputTypeName}!]!`,
};
}

public get connectOrCreateWhereInputFieldNames() {
return {
node: `${this.uniqueWhereInputTypeName}!`,
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
* limitations under the License.
*/

import type { ConcreteEntityAdapter } from "../../entity/model-adapters/ConcreteEntityAdapter";
import { upperFirst } from "../../../utils/upper-first";
import { isUnionEntity } from "../../../translate/queryAST/utils/is-union-entity";
import type { RelationshipDeclarationAdapter } from "./RelationshipDeclarationAdapter";
import type { ConcreteEntityAdapter } from "../../entity/model-adapters/ConcreteEntityAdapter";
import type { RelationshipAdapter } from "./RelationshipAdapter";
import type { RelationshipDeclarationAdapter } from "./RelationshipDeclarationAdapter";

export abstract class RelationshipBaseOperations<T extends RelationshipAdapter | RelationshipDeclarationAdapter> {
protected constructor(protected readonly relationship: T) {}
Expand Down Expand Up @@ -105,24 +104,6 @@ export abstract class RelationshipBaseOperations<T extends RelationshipAdapter |
}DisconnectFieldInput`;
}

public getConnectOrCreateInputTypeName(): string {
return `${this.prefixForTypename}ConnectOrCreateInput`;
}

public getConnectOrCreateFieldInputTypeName(concreteTargetEntityAdapter?: ConcreteEntityAdapter): string {
if (isUnionEntity(this.relationship.target)) {
if (!concreteTargetEntityAdapter) {
throw new Error("missing concreteTargetEntityAdapter");
}
return `${this.prefixForTypename}${concreteTargetEntityAdapter.name}ConnectOrCreateFieldInput`;
}
return `${this.prefixForTypename}ConnectOrCreateFieldInput`;
}

public getConnectOrCreateOnCreateFieldInputTypeName(concreteTargetEntityAdapter: ConcreteEntityAdapter): string {
return `${this.getConnectOrCreateFieldInputTypeName(concreteTargetEntityAdapter)}OnCreate`;
}

public get connectionFieldName(): string {
return `${this.relationship.name}Connection`;
}
Expand Down Expand Up @@ -199,12 +180,4 @@ export abstract class RelationshipBaseOperations<T extends RelationshipAdapter |
public get edgeAggregationWhereInputTypeName(): string {
return `${this.edgePrefix}AggregationWhereInput`;
}

public getConnectOrCreateInputFields(target: ConcreteEntityAdapter) {
// TODO: use this._target in the end; currently passed-in as argument because unions need this per refNode
return {
where: `${target.operations.connectOrCreateWhereInputTypeName}!`,
onCreate: `${this.getConnectOrCreateOnCreateFieldInputTypeName(target)}!`,
};
}
}
7 changes: 0 additions & 7 deletions packages/graphql/src/schema/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,3 @@ 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_CONNECT_OR_CREATE = {
name: DEPRECATED,
args: {
reason: "The connectOrCreate operation is deprecated and will be removed",
},
};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
augmentObjectOrInterfaceTypeWithRelationshipField,
} from "../generation/augment-object-or-interface";
import { augmentConnectInputTypeWithConnectFieldInput } from "../generation/connect-input";
import { withConnectOrCreateInputType } from "../generation/connect-or-create-input";
import {
augmentCreateInputTypeWithRelationshipsInput,
withCreateInputType,
Expand Down Expand Up @@ -315,15 +314,7 @@ function createRelationshipFieldsForTarget({

if (relationshipAdapter.target instanceof InterfaceEntityAdapter) {
withFieldInputType({ relationshipAdapter, composer, userDefinedFieldDirectives, features });
} else {
withConnectOrCreateInputType({
relationshipAdapter,
composer,
userDefinedFieldDirectives,
deprecatedDirectives,
});
}

composeNode.addFields(
augmentObjectOrInterfaceTypeWithRelationshipField({
relationshipAdapter,
Expand Down
Loading

0 comments on commit 21ab3d6

Please sign in to comment.