Skip to content

Commit

Permalink
Merge pull request #127 from oskarhane/rename-verify-compat
Browse files Browse the repository at this point in the history
Rename `.verifyDatabase` -> `.checkNeo4jCompat`
  • Loading branch information
oskarhane authored Apr 7, 2021
2 parents 29cdd2a + bde2247 commit dd08c67
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 31 deletions.
6 changes: 3 additions & 3 deletions docs/asciidoc/api-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const neo4jGraphQL = new Neo4jGraphQL({

=== Methods

==== `verifyDatabase`
Reference: <<drivers-and-config-verifyDatabase>>
==== `checkNeo4jCompat`
Reference: <<drivers-and-config-checkNeo4jCompat>>

== `OGM`
Reference: <<ogm-api-reference>>
Reference: <<ogm-api-reference>>
10 changes: 5 additions & 5 deletions docs/asciidoc/driver-and-config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,24 @@ const driver = neo4j.driver(
const ogm = new OGM({ typeDefs, driver });
----

[[drivers-and-config-verifyDatabase]]
== `verifyDatabase`
Use the `verifyDatabase` method available on either `Neo4jGraphQL` or the `OGM` to ensure the specified DBMS has the required; versions, functions and procedures.
[[drivers-and-config-checkNeo4jCompat]]
== `checkNeo4jCompat`
Use the `checkNeo4jCompat` method available on either `Neo4jGraphQL` or the `OGM` to ensure the specified DBMS has the required; versions, functions and procedures.

==== `Neo4jGraphQL`

[source, javascript]
----
const neoSchema = new Neo4jGraphQL({ typeDefs, driver });
await neoSchema.verifyDatabase();
await neoSchema.checkNeo4jCompat();
----

==== `OGM`

[source, javascript]
----
const ogm = new OGM({ typeDefs, driver });
await ogm.verifyDatabase();
await ogm.checkNeo4jCompat();
----

== Specifying Neo4j Database
Expand Down
4 changes: 2 additions & 2 deletions packages/graphql/src/classes/Neo4jGraphQL.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ describe("Neo4jGraphQL", () => {
});

describe("methods", () => {
describe("verifyDatabase", () => {
describe("checkNeo4jCompat", () => {
test("should throw neo4j-driver Driver missing", async () => {
const neoSchema = new Neo4jGraphQL({ typeDefs: "type User {id: ID}" });

await expect(neoSchema.verifyDatabase()).rejects.toThrow(`neo4j-driver Driver missing`);
await expect(neoSchema.checkNeo4jCompat()).rejects.toThrow(`neo4j-driver Driver missing`);
});
});

Expand Down
6 changes: 3 additions & 3 deletions packages/graphql/src/classes/Neo4jGraphQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { parseResolveInfo, ResolveTree } from "graphql-parse-resolve-info";
import type { DriverConfig } from "../types";
import { makeAugmentedSchema } from "../schema";
import Node from "./Node";
import { verifyDatabase } from "../utils";
import { checkNeo4jCompat } from "../utils";
import { getJWT } from "../auth/index";

export type SchemaDirectives = IExecutableSchemaDefinition["schemaDirectives"];
Expand Down Expand Up @@ -117,15 +117,15 @@ class Neo4jGraphQL {
});
}

async verifyDatabase(input: { driver?: Driver; driverConfig?: DriverConfig } = {}): Promise<void> {
async checkNeo4jCompat(input: { driver?: Driver; driverConfig?: DriverConfig } = {}): Promise<void> {
const driver = input.driver || this.driver;
const driverConfig = input.driverConfig || this.driverConfig;

if (!driver) {
throw new Error("neo4j-driver Driver missing");
}

return verifyDatabase({ driver, driverConfig });
return checkNeo4jCompat({ driver, driverConfig });
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@

export { default as trimmer } from "./trimmer";
export { default as execute } from "./execute";
export { default as verifyDatabase } from "./verify-database";
export { default as checkNeo4jCompat } from "./verify-database";
export { default as upperFirstLetter } from "./upper-first-letter";
18 changes: 9 additions & 9 deletions packages/graphql/src/utils/verify-database.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
*/

import { Driver, Session } from "neo4j-driver";
import verifyDatabase from "./verify-database";
import checkNeo4jCompat from "./verify-database";
import { MIN_NEO4J_VERSION, MIN_APOC_VERSION, REQUIRED_APOC_FUNCTIONS, REQUIRED_APOC_PROCEDURES } from "../constants";
import { DriverConfig } from "../types";

describe("verifyDatabase", () => {
describe("checkNeo4jCompat", () => {
test("should add driver config to session", async () => {
// @ts-ignore
const fakeSession: Session = {
Expand Down Expand Up @@ -60,7 +60,7 @@ describe("verifyDatabase", () => {
verifyConnectivity: () => undefined,
};

await verifyDatabase({ driver: fakeDriver, driverConfig });
await checkNeo4jCompat({ driver: fakeDriver, driverConfig });
});

test("should throw expected Neo4j version", async () => {
Expand All @@ -84,7 +84,7 @@ describe("verifyDatabase", () => {
verifyConnectivity: () => undefined,
};

await expect(verifyDatabase({ driver: fakeDriver })).rejects.toThrow(
await expect(checkNeo4jCompat({ driver: fakeDriver })).rejects.toThrow(
`Expected minimum Neo4j version: '${MIN_NEO4J_VERSION}' received: '${invalidVersion}'`
);
});
Expand All @@ -110,7 +110,7 @@ describe("verifyDatabase", () => {
verifyConnectivity: () => undefined,
};

await expect(verifyDatabase({ driver: fakeDriver })).rejects.toThrow(
await expect(checkNeo4jCompat({ driver: fakeDriver })).rejects.toThrow(
`Expected minimum APOC version: '${MIN_APOC_VERSION}' received: '${invalidApocVersion}'`
);
});
Expand Down Expand Up @@ -142,7 +142,7 @@ describe("verifyDatabase", () => {
verifyConnectivity: () => undefined,
};

await expect(verifyDatabase({ driver: fakeDriver })).rejects.toThrow(
await expect(checkNeo4jCompat({ driver: fakeDriver })).rejects.toThrow(
`Missing APOC functions: [ ${REQUIRED_APOC_FUNCTIONS.join(", ")} ]`
);
});
Expand Down Expand Up @@ -175,7 +175,7 @@ describe("verifyDatabase", () => {
verifyConnectivity: () => undefined,
};

await expect(verifyDatabase({ driver: fakeDriver })).rejects.toThrow(
await expect(checkNeo4jCompat({ driver: fakeDriver })).rejects.toThrow(
`Missing APOC procedures: [ ${REQUIRED_APOC_PROCEDURES.join(", ")} ]`
);
});
Expand Down Expand Up @@ -208,7 +208,7 @@ describe("verifyDatabase", () => {
verifyConnectivity: () => undefined,
};

expect(await verifyDatabase({ driver: fakeDriver })).toBeUndefined();
expect(await checkNeo4jCompat({ driver: fakeDriver })).toBeUndefined();
});

test("should throw no errors with valid DB (greater versions)", async () => {
Expand Down Expand Up @@ -239,6 +239,6 @@ describe("verifyDatabase", () => {
verifyConnectivity: () => undefined,
};

expect(await verifyDatabase({ driver: fakeDriver })).toBeUndefined();
expect(await checkNeo4jCompat({ driver: fakeDriver })).toBeUndefined();
});
});
4 changes: 2 additions & 2 deletions packages/graphql/src/utils/verify-database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface DBInfo {
procedures: string[];
}

async function verifyDatabase({ driver, driverConfig }: { driver: Driver; driverConfig?: DriverConfig }) {
async function checkNeo4jCompat({ driver, driverConfig }: { driver: Driver; driverConfig?: DriverConfig }) {
await driver.verifyConnectivity();

const sessionParams: {
Expand Down Expand Up @@ -89,4 +89,4 @@ async function verifyDatabase({ driver, driverConfig }: { driver: Driver; driver
}
}

export default verifyDatabase;
export default checkNeo4jCompat;
2 changes: 1 addition & 1 deletion packages/graphql/tests/integration/find.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe("find", () => {
`;

try {
await neoSchema.verifyDatabase();
await neoSchema.checkNeo4jCompat();

await session.run(
`
Expand Down
4 changes: 2 additions & 2 deletions packages/ogm/src/classes/OGM.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ describe("OGM", () => {
});
});

describe("verifyDatabase", () => {
describe("checkNeo4jCompat", () => {
test("should neo4j-driver Driver missing", async () => {
// @ts-ignore
const ogm = new OGM({ typeDefs: "type User {id: ID}" });

await expect(ogm.verifyDatabase()).rejects.toThrow(`neo4j-driver Driver missing`);
await expect(ogm.checkNeo4jCompat()).rejects.toThrow(`neo4j-driver Driver missing`);
});
});

Expand Down
4 changes: 2 additions & 2 deletions packages/ogm/src/classes/OGM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ class OGM {
return found;
}

async verifyDatabase(input: { driver?: Driver } = {}): Promise<void> {
async checkNeo4jCompat(input: { driver?: Driver } = {}): Promise<void> {
const driver = input.driver || this.input.driver;

return this.neoSchema.verifyDatabase({ driver });
return this.neoSchema.checkNeo4jCompat({ driver });
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ogm/tests/integration/ogm.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe("OGM", () => {
});

try {
await ogm.verifyDatabase();
await ogm.checkNeo4jCompat();

await session.run(`
CREATE (:Movie {id: "${id}"})
Expand Down

0 comments on commit dd08c67

Please sign in to comment.