Skip to content

Commit

Permalink
Merge branch '6.x' into breaking/remove-non-aggregation-filters
Browse files Browse the repository at this point in the history
  • Loading branch information
darrellwarde committed Oct 9, 2024
2 parents de0599f + 7e356f1 commit f7f1125
Show file tree
Hide file tree
Showing 110 changed files with 33 additions and 915 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-dots-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@neo4j/graphql": major
---

Remove no-op option to remove `stringAggregation` deprecated fields.
6 changes: 6 additions & 0 deletions .changeset/fast-timers-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@neo4j/graphql": major
"@neo4j/graphql-ogm": major
---

The deprecated `bookmark` field has been removed due to bookmarks now be handled internally by the database driver.
12 changes: 0 additions & 12 deletions packages/graphql/src/classes/Executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ export type Neo4jGraphQLSessionConfig = Pick<SessionConfig, "database" | "impers
export class Executor {
private executionContext: ExecutionContext;

/**
* @deprecated Will be removed in 5.0.0.
*/
public lastBookmark: string | null;

private cypherQueryOptions: CypherQueryOptions | undefined;

private sessionConfig: SessionConfig | undefined;
Expand All @@ -112,7 +107,6 @@ export class Executor {
}: ExecutorConstructorParam) {
this.executionContext = executionContext;
this.cypherQueryOptions = cypherQueryOptions;
this.lastBookmark = null;
this.cypherQueryOptions = cypherQueryOptions;
this.sessionConfig = sessionConfig;
this.cypherParams = cypherParams;
Expand Down Expand Up @@ -276,12 +270,6 @@ export class Executor {
break;
}

// TODO: remove in 5.0.0, only kept to not make client breaking changes in 4.0.0
const lastBookmark = session.lastBookmarks();
if (lastBookmark[0]) {
this.lastBookmark = lastBookmark[0];
}

return result;
}

Expand Down
5 changes: 1 addition & 4 deletions packages/graphql/src/graphql/objects/CreateInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@
* limitations under the License.
*/

import { GraphQLInt, GraphQLNonNull, GraphQLObjectType, GraphQLString } from "graphql";
import { GraphQLInt, GraphQLNonNull, GraphQLObjectType } from "graphql";

export const CreateInfo = new GraphQLObjectType({
name: "CreateInfo",
description: "Information about the number of nodes and relationships created during a create mutation",
fields: {
bookmark: {
type: GraphQLString,
},
nodesCreated: {
type: new GraphQLNonNull(GraphQLInt),
},
Expand Down
5 changes: 1 addition & 4 deletions packages/graphql/src/graphql/objects/DeleteInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@
* limitations under the License.
*/

import { GraphQLInt, GraphQLNonNull, GraphQLObjectType, GraphQLString } from "graphql";
import { GraphQLInt, GraphQLNonNull, GraphQLObjectType } from "graphql";

export const DeleteInfo = new GraphQLObjectType({
name: "DeleteInfo",
description: "Information about the number of nodes and relationships deleted during a delete mutation",
fields: {
bookmark: {
type: GraphQLString,
},
nodesDeleted: {
type: new GraphQLNonNull(GraphQLInt),
},
Expand Down
5 changes: 1 addition & 4 deletions packages/graphql/src/graphql/objects/UpdateInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@
* limitations under the License.
*/

import { GraphQLInt, GraphQLNonNull, GraphQLObjectType, GraphQLString } from "graphql";
import { GraphQLInt, GraphQLNonNull, GraphQLObjectType } from "graphql";

export const UpdateInfo = new GraphQLObjectType({
name: "UpdateInfo",
description:
"Information about the number of nodes and relationships created and deleted during an update mutation",
fields: {
bookmark: {
type: GraphQLString,
},
nodesCreated: {
type: new GraphQLNonNull(GraphQLInt),
},
Expand Down
66 changes: 0 additions & 66 deletions packages/graphql/src/schema/deprecation-map.ts

This file was deleted.

15 changes: 0 additions & 15 deletions packages/graphql/src/schema/make-augmented-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ import { augmentVectorSchema } from "./augment/vector";
import { createConnectionFields } from "./create-connection-fields";
import { addGlobalNodeFields } from "./create-global-nodes";
import { createRelationshipFields } from "./create-relationship-fields/create-relationship-fields";
import { bookmarkDeprecationMap } from "./deprecation-map";
import { AugmentedSchemaGenerator } from "./generation/AugmentedSchemaGenerator";
import { withAggregateSelectionType } from "./generation/aggregate-types";
import { withCreateInputType } from "./generation/create-input";
Expand All @@ -85,7 +84,6 @@ import { withObjectType } from "./generation/object-type";
import { withMutationResponseTypes } from "./generation/response-types";
import { withOptionsInputType } from "./generation/sort-and-options-input";
import { withUpdateInputType } from "./generation/update-input";
import { shouldAddDeprecatedFields } from "./generation/utils";
import { withUniqueWhereInputType, withWhereInputType } from "./generation/where-input";
import getNodes from "./get-nodes";
import { getResolveAndSubscriptionMethods } from "./get-resolve-and-subscription-methods";
Expand Down Expand Up @@ -152,19 +150,6 @@ function makeAugmentedSchema({
composer.addTypeDefs(print({ kind: Kind.DOCUMENT, definitions: pipedDefs }));
}

// Loop over all entries in the deprecation map and add field deprecations to all types in the map.
for (const [typeName, deprecatedFields] of bookmarkDeprecationMap) {
const typeComposer = composer.getOTC(typeName);

if (shouldAddDeprecatedFields(features, "bookmark")) {
typeComposer.deprecateFields(
deprecatedFields.reduce((acc, { field, reason }) => ({ ...acc, [field]: reason }), {})
);
} else {
typeComposer.removeField(deprecatedFields.map((field) => field.field));
}
}

// TODO: ideally move these in getSubgraphSchema()
if (subgraph) {
const shareable = subgraph.getFullyQualifiedDirectiveName(SHAREABLE);
Expand Down
12 changes: 1 addition & 11 deletions packages/graphql/src/schema/resolvers/mutation/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,7 @@ export function createResolver({
node: Node;
concreteEntityAdapter: ConcreteEntityAdapter;
}) {
async function resolve(
_root: any,
args: any,
context: Neo4jGraphQLComposedContext,
info: GraphQLResolveInfo
): Promise<{
info: {
bookmark: string | null;
};
}> {
async function resolve(_root: any, args: any, context: Neo4jGraphQLComposedContext, info: GraphQLResolveInfo) {
const resolveTree = getNeo4jResolveTree(info, { args });

(context as Neo4jGraphQLTranslationContext).resolveTree = resolveTree;
Expand All @@ -67,7 +58,6 @@ export function createResolver({

const resolveResult = {
info: {
bookmark: executeResult.bookmark,
...executeResult.statistics,
},
};
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/src/schema/resolvers/mutation/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function deleteResolver({

publishEventsToSubscriptionMechanism(executeResult, context.features?.subscriptions, context.schemaModel);

return { bookmark: executeResult.bookmark, ...executeResult.statistics };
return executeResult.statistics;
}

const hasDeleteInput = composer.has(concreteEntityAdapter.operations.deleteInputTypeName);
Expand Down
13 changes: 1 addition & 12 deletions packages/graphql/src/schema/resolvers/mutation/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,7 @@ export function updateResolver({
concreteEntityAdapter: ConcreteEntityAdapter;
features?: Neo4jFeaturesSettings;
}): ObjectTypeComposerFieldConfigAsObjectDefinition<any, any> {
async function resolve(
_root: any,
args: any,
context: Neo4jGraphQLComposedContext,
info: GraphQLResolveInfo
): Promise<{
info: {
bookmark: string | null;
};
}> {
async function resolve(_root: any, args: any, context: Neo4jGraphQLComposedContext, info: GraphQLResolveInfo) {
const resolveTree = getNeo4jResolveTree(info, { args });

(context as Neo4jGraphQLTranslationContext).resolveTree = resolveTree;
Expand All @@ -82,10 +73,8 @@ export function updateResolver({
selection.kind === Kind.FIELD && selection.name.value === concreteEntityAdapter.plural
);

// TODO: Ask why we are returning bookmark still
const resolveResult = {
info: {
bookmark: executeResult.bookmark,
...executeResult.statistics,
},
};
Expand Down
2 changes: 0 additions & 2 deletions packages/graphql/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,8 @@ export type Neo4jFeaturesSettings = {
* NOTE: this will not remove user defined deprecated fields
**/
excludeDeprecatedFields?: {
bookmark?: boolean;
implicitEqualFilters?: boolean;
arrayFilters?: boolean;
stringAggregation?: boolean;
aggregationFilters?: boolean;
deprecatedOptionsArgument?: boolean;
nestedUpdateOperationsFields?: boolean;
Expand Down
6 changes: 2 additions & 4 deletions packages/graphql/src/utils/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@
* limitations under the License.
*/

import type { SessionMode, QueryResult } from "neo4j-driver";
import Debug from "debug";
import { DEBUG_EXECUTE } from "../constants";
import type { GraphQLResolveInfo } from "graphql";
import type { QueryResult, SessionMode } from "neo4j-driver";
import { DEBUG_EXECUTE } from "../constants";
import type { Neo4jGraphQLComposedContext } from "../schema/resolvers/composition/wrap-query-and-mutation";

const debug = Debug(DEBUG_EXECUTE);

export interface ExecuteResult {
bookmark: string | null;
result: QueryResult;
statistics: Record<string, number>;
records: Record<PropertyKey, any>[];
Expand Down Expand Up @@ -56,7 +55,6 @@ async function execute({
debug(`Execute successful, received ${records.length} records`);

return {
bookmark: context.executor.lastBookmark,
result,
statistics: result.summary.counters.updates(),
records,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,6 @@ describe("@alias directive", () => {
${AliasDirectiveTestUser.plural} {
id
}
info {
bookmark
}
}
}
Expand Down
17 changes: 8 additions & 9 deletions packages/graphql/tests/integration/info.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ describe("info", () => {
mutation($title: String!, $name: String!) {
${Movie.operations.create}(input: [{ title: $title, actors: { create: [{ node: { name: $name } }] } }]) {
info {
bookmark
nodesCreated
relationshipsCreated
}
Expand All @@ -80,7 +79,6 @@ describe("info", () => {

expect(gqlResult.errors).toBeFalsy();

expect(typeof (gqlResult?.data as any)?.[Movie.operations.create].info.bookmark).toBe("string");
expect((gqlResult?.data as any)?.[Movie.operations.create].info.nodesCreated).toBe(2);
expect((gqlResult?.data as any)?.[Movie.operations.create].info.relationshipsCreated).toBe(1);
expect((gqlResult?.data as any)?.[Movie.operations.create][Movie.plural]).toEqual([
Expand All @@ -104,7 +102,8 @@ describe("info", () => {
const query = `
mutation($id: ID!) {
${Movie.operations.delete}(where: { id_EQ: $id }) {
bookmark
nodesDeleted
relationshipsDeleted
}
}
`;
Expand All @@ -115,7 +114,8 @@ describe("info", () => {

expect(gqlResult.errors).toBeFalsy();

expect(typeof (gqlResult?.data as any)?.[Movie.operations.delete].bookmark).toBe("string");
expect((gqlResult?.data as any)?.[Movie.operations.delete].nodesDeleted).toBe(0);
expect((gqlResult?.data as any)?.[Movie.operations.delete].relationshipsDeleted).toBe(0);
});

test("should return info from an update mutation", async () => {
Expand All @@ -134,12 +134,12 @@ describe("info", () => {
const query = `
mutation($id: ID!) {
${Movie.operations.update}(where: { id_EQ: $id }) {
info {
bookmark
}
${Movie.plural} {
id
}
info {
nodesCreated
}
}
}
`;
Expand All @@ -149,7 +149,6 @@ describe("info", () => {
});

expect(gqlResult.errors).toBeFalsy();

expect(typeof (gqlResult?.data as any)[Movie.operations.update].info.bookmark).toBe("string");
expect((gqlResult?.data as any)?.[Movie.operations.update].info.nodesCreated).toBe(0);
});
});
6 changes: 0 additions & 6 deletions packages/graphql/tests/integration/issues/1348.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ describe("https://github.com/neo4j/graphql/issues/1348", () => {
productTitle: "TestFilm1"
}
]) {
info {
bookmark
}
${ProgrammeItem.plural} {
productTitle
episodeNumber
Expand All @@ -100,9 +97,6 @@ describe("https://github.com/neo4j/graphql/issues/1348", () => {
where: { productTitle_EQ: "TestFilm1" }
connect: { relatedTo: { where: { node: { productTitle_EQ: "TestEpisode1" } } } }
) {
info {
bookmark
}
${ProgrammeItem.plural} {
productTitle
episodeNumber
Expand Down
Loading

0 comments on commit f7f1125

Please sign in to comment.