Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate options of assertIndexesAndConstraints and remove from tests #5632

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/afraid-cows-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@neo4j/graphql": patch
---

The `options` argument of `assertIndexesAndConstraints` has been deprecated and the creation of indexes and constraints will no longer be support in the next major version of the library.
3 changes: 3 additions & 0 deletions packages/graphql/src/classes/Neo4jGraphQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ class Neo4jGraphQL {
}: {
driver?: Driver;
sessionConfig?: Neo4jGraphQLSessionConfig;
/**
* @deprecated The ability to create indexes and constraints will be removed in version 6.0.0
*/
options?: AssertIndexesAndConstraintsOptions;
} = {}): Promise<void> {
if (!(this.executableSchema || this.subgraphSchema)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,13 @@ describe("@fulltext directive", () => {
neoSchema = await testHelper.initNeo4jGraphQL({
typeDefs,
});

await testHelper.createFulltextIndex(`${personType.name}Index`, personType.name, ["name"]);

await neoSchema.getSchema();
await neoSchema.assertIndexesAndConstraints({
driver,
sessionConfig: { database: databaseName },
options: { create: true },
});

await testHelper.executeCypher(
Expand Down Expand Up @@ -1244,11 +1246,13 @@ describe("@fulltext directive", () => {
},
},
});

await testHelper.createFulltextIndex(`${personType.name}Index`, personType.name, ["name"]);

await neoSchema.getSchema();
await neoSchema.assertIndexesAndConstraints({
driver,
sessionConfig: { database: databaseName },
options: { create: true },
});

const query = `
Expand Down Expand Up @@ -1305,11 +1309,13 @@ describe("@fulltext directive", () => {
},
},
});

await testHelper.createFulltextIndex(`${personType.name}Index`, personType.name, ["name"]);

await neoSchema.getSchema();
await neoSchema.assertIndexesAndConstraints({
driver,
sessionConfig: { database: databaseName },
options: { create: true },
});

const query = `
Expand Down Expand Up @@ -1366,11 +1372,13 @@ describe("@fulltext directive", () => {
},
},
});

await testHelper.createFulltextIndex(`${personType.name}Index`, personType.name, ["name"]);

await neoSchema.getSchema();
await neoSchema.assertIndexesAndConstraints({
driver,
sessionConfig: { database: databaseName },
options: { create: true },
});

const query = `
Expand Down Expand Up @@ -1442,11 +1450,13 @@ describe("@fulltext directive", () => {
},
},
});

await testHelper.createFulltextIndex(`${personType.name}Index`, personType.name, ["name"]);

await neoSchema.getSchema();
await neoSchema.assertIndexesAndConstraints({
driver,
sessionConfig: { database: databaseName },
options: { create: true },
});

const query = `
Expand Down Expand Up @@ -1498,11 +1508,13 @@ describe("@fulltext directive", () => {
},
},
});

await testHelper.createFulltextIndex(`${personType.name}Index`, personType.name, ["name"]);

await neoSchema.getSchema();
await neoSchema.assertIndexesAndConstraints({
driver,
sessionConfig: { database: databaseName },
options: { create: true },
});

const query = `
Expand Down Expand Up @@ -1557,11 +1569,13 @@ describe("@fulltext directive", () => {
},
},
});

await testHelper.createFulltextIndex(`${personType.name}Index`, personType.name, ["name"]);

await neoSchema.getSchema();
await neoSchema.assertIndexesAndConstraints({
driver,
sessionConfig: { database: databaseName },
options: { create: true },
});

const query = `
Expand Down Expand Up @@ -1617,11 +1631,13 @@ describe("@fulltext directive", () => {
},
},
});

await testHelper.createFulltextIndex(`${personType.name}Index`, personType.name, ["name"]);

await neoSchema.getSchema();
await neoSchema.assertIndexesAndConstraints({
driver,
sessionConfig: { database: databaseName },
options: { create: true },
});

const query = `
Expand Down Expand Up @@ -1669,11 +1685,13 @@ describe("@fulltext directive", () => {
neoSchema = await testHelper.initNeo4jGraphQL({
typeDefs,
});

await testHelper.createFulltextIndex(`${movieType.name}Index`, movieType.name, ["title", "description"]);

await neoSchema.getSchema();
await neoSchema.assertIndexesAndConstraints({
driver,
sessionConfig: { database: databaseName },
options: { create: true },
});

const query = `
Expand Down Expand Up @@ -1736,11 +1754,13 @@ describe("@fulltext directive", () => {
neoSchema = await testHelper.initNeo4jGraphQL({
typeDefs,
});

await testHelper.createFulltextIndex(`${personType.name}CustomIndex`, personType.name, ["name"]);

await neoSchema.getSchema();
await neoSchema.assertIndexesAndConstraints({
driver,
sessionConfig: { database: databaseName },
options: { create: true },
});

const query = `
Expand Down Expand Up @@ -1793,11 +1813,13 @@ describe("@fulltext directive", () => {
neoSchema = await testHelper.initNeo4jGraphQL({
typeDefs,
});

await testHelper.createFulltextIndex(`${movieType.name}Index`, movieType.name, ["title", "description"]);

await neoSchema.getSchema();
await neoSchema.assertIndexesAndConstraints({
driver,
sessionConfig: { database: databaseName },
options: { create: true },
});

const query = `
Expand Down Expand Up @@ -1862,11 +1884,14 @@ describe("@fulltext directive", () => {
neoSchema = await testHelper.initNeo4jGraphQL({
typeDefs,
});

await testHelper.createFulltextIndex(`${movieType.name}CustomIndex`, movieType.name, ["title"]);
await testHelper.createFulltextIndex(`${movieType.name}CustomIndex2`, movieType.name, ["description"]);

await neoSchema.getSchema();
await neoSchema.assertIndexesAndConstraints({
driver,
sessionConfig: { database: databaseName },
options: { create: true },
});

const query1 = `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ describe("@vector directive - filtering", () => {
await neoSchema.assertIndexesAndConstraints({
driver,
sessionConfig: { database: databaseName },
options: { create: true },
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ describe("@vector directive - pagination", () => {
await neoSchema.assertIndexesAndConstraints({
driver,
sessionConfig: { database: databaseName },
options: { create: true },
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ describe("@vector directive - Query", () => {
await neoSchema.assertIndexesAndConstraints({
driver,
sessionConfig: { database: databaseName },
options: { create: true },
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ describe("@vector directive - Query", () => {
await neoSchema.assertIndexesAndConstraints({
driver,
sessionConfig: { database: databaseName },
options: { create: true },
});
});

Expand Down
4 changes: 3 additions & 1 deletion packages/graphql/tests/integration/issues/5378.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ describe("https:/neo4j/graphql/issues/5378", () => {
typeDefs,
});

await testHelper.createFulltextIndex("fulltext_index_space_name_number", Space.name, ["Name", "Number"]);
await testHelper.createUniqueConstraint("unique_constraint_space_id", Space.name, "Id");

await neoSchema.getSchema();
await neoSchema.assertIndexesAndConstraints({
driver: await testHelper.getDriver(),
sessionConfig: { database: databaseName },
options: { create: true },
});
});

Expand Down
20 changes: 20 additions & 0 deletions packages/graphql/tests/utils/tests-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,26 @@ export class TestHelper {
return new Neo4jDatabaseInfo(rawVersion, edition);
}

public async createFulltextIndex(name: string, label: string, properties: string[]): Promise<void> {
const cypher = [
`CREATE FULLTEXT INDEX ${name}`,
`IF NOT EXISTS FOR (n:${label})`,
`ON EACH [${properties.map((p) => `n.${p}`).join(", ")}]`,
].join(" ");

await this.executeCypher(cypher);
}

public async createUniqueConstraint(name: string, label: string, property: string): Promise<void> {
const cypher = [
`CREATE CONSTRAINT ${name}`,
`IF NOT EXISTS FOR (n:${label})`,
`REQUIRE n.${property} IS UNIQUE`,
].join(" ");

await this.executeCypher(cypher);
}

private async checkConnectivity(driver: neo4j.Driver): Promise<string> {
if (process.env.USE_DEFAULT_DB) {
return this.checkConnectivityToDefaultDatabase(driver);
Expand Down
Loading