Skip to content

Commit

Permalink
Merge pull request #5630 from neo4j/remove-deprecated-update-input
Browse files Browse the repository at this point in the history
Remove deprecated update input
  • Loading branch information
angrykoala authored Oct 10, 2024
2 parents 8206edd + 31d83dc commit b13c19e
Show file tree
Hide file tree
Showing 136 changed files with 2,259 additions and 6,458 deletions.
37 changes: 37 additions & 0 deletions .changeset/mighty-cameras-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
"@neo4j/graphql": major
---

Remove deprecated top level arguments for nested operations in mutations:

- create
- delete
- connect
- disconnect
- connectOrCreate

For example, the following is no longer valid:

_invalid_

```graphql
mutation UpdatePeople {
updatePeople(create: { movies: { node: { title: "The Good" } } }) {
people {
name
}
}
}
```

_valid_

```graphql
mutation UpdatePeople {
updatePeople(update: { movies: { create: { node: { title: "The Good" } } } }) {
people {
name
}
}
}
```
35 changes: 0 additions & 35 deletions packages/graphql/src/schema/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,3 @@ export const DEPRECATE_OPTIONS_ARGUMENT = {
reason: "Query options argument is deprecated, please use pagination arguments like limit, offset and sort instead.",
},
};

export const DEPRECATE_UPDATE_CREATE_INPUT_FIELD = {
name: DEPRECATED,
args: {
reason: "Top level create input argument in update is deprecated. Use the nested create field in the relationship within the update argument",
},
};

export const DEPRECATE_UPDATE_DELETE_INPUT_FIELD = {
name: DEPRECATED,
args: {
reason: "Top level delete input argument in update is deprecated. Use the nested delete field in the relationship within the update argument",
},
};

export const DEPRECATE_UPDATE_CONNECT_INPUT_FIELD = {
name: DEPRECATED,
args: {
reason: "Top level connect input argument in update is deprecated. Use the nested connect field in the relationship within the update argument",
},
};

export const DEPRECATE_UPDATE_DISCONNECT_INPUT_FIELD = {
name: DEPRECATED,
args: {
reason: "Top level disconnect input argument in update is deprecated. Use the nested disconnect field in the relationship within the update argument",
},
};

export const DEPRECATE_UPDATE_CONNECT_OR_CREATE_INPUT_FIELD = {
name: DEPRECATED,
args: {
reason: "Top level connectOrCreate input argument in update is deprecated. Use the nested connectOrCreate field in the relationship within the update argument",
},
};
100 changes: 1 addition & 99 deletions packages/graphql/src/schema/resolvers/mutation/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,61 +54,6 @@ describe("Update resolver", () => {
expect(result.args).toMatchObject({
where: "MovieWhere",
update: "MovieUpdateInput",
connect: {
directives: [
{
args: {
reason: "Top level connect input argument in update is deprecated. Use the nested connect field in the relationship within the update argument",
},
name: "deprecated",
},
],
type: "MovieConnectInput",
},
connectOrCreate: {
directives: [
{
args: {
reason: "Top level connectOrCreate input argument in update is deprecated. Use the nested connectOrCreate field in the relationship within the update argument",
},
name: "deprecated",
},
],
type: "MovieConnectOrCreateInput",
},
create: {
directives: [
{
args: {
reason: "Top level create input argument in update is deprecated. Use the nested create field in the relationship within the update argument",
},
name: "deprecated",
},
],
type: "MovieRelationInput",
},
delete: {
directives: [
{
args: {
reason: "Top level delete input argument in update is deprecated. Use the nested delete field in the relationship within the update argument",
},
name: "deprecated",
},
],
type: "MovieDeleteInput",
},
disconnect: {
directives: [
{
args: {
reason: "Top level disconnect input argument in update is deprecated. Use the nested disconnect field in the relationship within the update argument",
},
name: "deprecated",
},
],
type: "MovieDisconnectInput",
},
});
});
test("should return fewer fields based on number of InputTCs created", () => {
Expand Down Expand Up @@ -139,57 +84,14 @@ describe("Update resolver", () => {
expect(result.args).not.toMatchObject({
where: "MovieWhere",
update: "MovieUpdateInput",
connect: {
directives: [
{
args: {
reason: "Top level connect input argument in update is deprecated. Use the nested connect field in the relationship within the update argument",
},
name: "deprecated",
},
],
type: "MovieConnectInput",
},
disconnect: {
directives: [
{
args: {
reason: "Top level disconnect input argument in update is deprecated. Use the nested disconnect field in the relationship within the update argument",
},
name: "deprecated",
},
],
type: "MovieDisconnectInput",
},

create: "MovieRelationInput",
delete: "MovieDeleteInput",
connectOrCreate: "MovieConnectOrCreateInput",
});
expect(result.args).toMatchObject({
where: "MovieWhere",
update: "MovieUpdateInput",
connect: {
directives: [
{
args: {
reason: "Top level connect input argument in update is deprecated. Use the nested connect field in the relationship within the update argument",
},
name: "deprecated",
},
],
type: "MovieConnectInput",
},
disconnect: {
directives: [
{
args: {
reason: "Top level disconnect input argument in update is deprecated. Use the nested disconnect field in the relationship within the update argument",
},
name: "deprecated",
},
],
type: "MovieDisconnectInput",
},
});
});
});
41 changes: 0 additions & 41 deletions packages/graphql/src/schema/resolvers/mutation/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ import type { Neo4jFeaturesSettings } from "../../../types";
import type { Neo4jGraphQLTranslationContext } from "../../../types/neo4j-graphql-translation-context";
import { execute } from "../../../utils";
import getNeo4jResolveTree from "../../../utils/get-neo4j-resolve-tree";
import {
DEPRECATE_UPDATE_CONNECT_INPUT_FIELD,
DEPRECATE_UPDATE_CONNECT_OR_CREATE_INPUT_FIELD,
DEPRECATE_UPDATE_CREATE_INPUT_FIELD,
DEPRECATE_UPDATE_DELETE_INPUT_FIELD,
DEPRECATE_UPDATE_DISCONNECT_INPUT_FIELD,
} from "../../constants";
import { shouldAddDeprecatedFields } from "../../generation/utils";
import { publishEventsToSubscriptionMechanism } from "../../subscriptions/publish-events-to-subscription-mechanism";
import type { Neo4jGraphQLComposedContext } from "../composition/wrap-query-and-mutation";

Expand Down Expand Up @@ -89,39 +81,6 @@ export function updateResolver({

const relationFields: Record<string, string | ObjectTypeComposerArgumentConfigAsObjectDefinition> = {};

if (shouldAddDeprecatedFields(features, "nestedUpdateOperationsFields")) {
if (composer.has(concreteEntityAdapter.operations.updateMutationArgumentNames.connect)) {
relationFields.connect = {
type: concreteEntityAdapter.operations.updateMutationArgumentNames.connect,
directives: [DEPRECATE_UPDATE_CONNECT_INPUT_FIELD],
};
}
if (composer.has(concreteEntityAdapter.operations.updateMutationArgumentNames.disconnect)) {
relationFields.disconnect = {
type: concreteEntityAdapter.operations.updateMutationArgumentNames.disconnect,
directives: [DEPRECATE_UPDATE_DISCONNECT_INPUT_FIELD],
};
}
if (composer.has(concreteEntityAdapter.operations.updateMutationArgumentNames.create)) {
relationFields.create = {
type: concreteEntityAdapter.operations.updateMutationArgumentNames.create,
directives: [DEPRECATE_UPDATE_CREATE_INPUT_FIELD],
};
}
if (composer.has(concreteEntityAdapter.operations.updateMutationArgumentNames.delete)) {
relationFields.delete = {
type: concreteEntityAdapter.operations.updateMutationArgumentNames.delete,
directives: [DEPRECATE_UPDATE_DELETE_INPUT_FIELD],
};
}
if (composer.has(concreteEntityAdapter.operations.updateMutationArgumentNames.connectOrCreate)) {
relationFields.connectOrCreate = {
type: concreteEntityAdapter.operations.updateMutationArgumentNames.connectOrCreate,
directives: [DEPRECATE_UPDATE_CONNECT_OR_CREATE_INPUT_FIELD],
};
}
}

return {
type: `${concreteEntityAdapter.operations.mutationResponseTypeNames.update}!`,
resolve,
Expand Down
1 change: 0 additions & 1 deletion packages/graphql/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ export type Neo4jFeaturesSettings = {
excludeDeprecatedFields?: {
implicitEqualFilters?: boolean;
deprecatedOptionsArgument?: boolean;
nestedUpdateOperationsFields?: boolean;
};
vector?: Neo4jVectorSettings;
};
Expand Down
Loading

0 comments on commit b13c19e

Please sign in to comment.