Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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/poor-fans-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@neo4j/graphql": major
---

`neo4jDatabaseInfo` has been removed from the context. It is our belief that this has little utility in the library. If you regularly use different drivers connected to _different versions_ of Neo4j and require this feature, please raise an issue: https://github.com/neo4j/graphql/issues/new/choose
37 changes: 0 additions & 37 deletions docs/modules/ROOT/pages/reference/driver-configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -218,43 +218,6 @@ await startStandaloneServer(server, {
});
----

== Specifying Neo4j version

When a connection is established, the library automatically detect the version of the Neo4j instance connected.
The version will be then stored and used for the following queries.
It is also possible to specify manually the Neo4j version in the Context.

=== Context

[source, javascript, indent=0]
----
import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';
import { Neo4jDatabaseInfo, Neo4jGraphQL } from "@neo4j/graphql";
import neo4j from "neo4j-driver";

const typeDefs = `#graphql
type User {
name: String
}
`;

const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
);

const neoSchema = new Neo4jGraphQL({ typeDefs, driver });

const server = new ApolloServer({
schema: await neoSchema.getSchema(),
});

await startStandaloneServer(server, {
context: async ({ req }) => ({ req, neo4jDatabaseInfo: new Neo4jDatabaseInfo("4.4") }),
});
----

[[driver-configuration-bookmarks]]
== Specifying Neo4j Bookmarks

Expand Down
1 change: 0 additions & 1 deletion packages/graphql/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { CartesianPoint } from "./graphql/objects/CartesianPoint";
import { Point } from "./graphql/objects/Point";

export {
Neo4jDatabaseInfo,
Neo4jGraphQL,
Neo4jGraphQLAuthenticationError,
Neo4jGraphQLConstructor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import Cypher from "@neo4j/cypher-builder";
import type { Neo4jDatabaseInfo, Node, Relationship } from "../classes";
import type { Node, Relationship } from "../classes";
import type { RelationField, Context, GraphQLWhereArg, PredicateReturn } from "../types";
import type { AggregationFieldRegexGroups } from "./where/utils";
import { aggregationFieldRegEx, whereRegEx } from "./where/utils";
Expand Down Expand Up @@ -256,8 +256,6 @@ function createEntityOperation(
param: paramName,
durationField,
pointField,
// Casting because this is definitely assigned in the wrapper
neo4jDatabaseInfo: context.neo4jDatabaseInfo as Neo4jDatabaseInfo,
});
const dbFieldName = mapToDbProperty(refNodeOrRelation, fieldName);
const collectedProperty =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* limitations under the License.
*/

import type { Neo4jDatabaseInfo } from "../../../classes/Neo4jDatabaseInfo";
import type { PointField, PrimitiveField } from "../../../types";
import Cypher from "@neo4j/cypher-builder";
import { createPointComparisonOperation } from "./create-point-comparison-operation";
Expand All @@ -29,14 +28,12 @@ export function createComparisonOperation({
param,
durationField,
pointField,
neo4jDatabaseInfo,
}: {
operator: string | undefined;
propertyRefOrCoalesce: Cypher.Property | Cypher.Function | Cypher.Variable;
param: Cypher.Param | Cypher.Property | Cypher.Function;
durationField: PrimitiveField | undefined;
pointField: PointField | undefined;
neo4jDatabaseInfo: Neo4jDatabaseInfo;
}): Cypher.ComparisonOp {
// TODO: consider if this conditional is the correct solution - should we make the function compatible?
if (!(param instanceof Cypher.Function) && pointField) {
Expand All @@ -45,7 +42,6 @@ export function createComparisonOperation({
propertyRefOrCoalesce,
param,
pointField,
neo4jDatabaseInfo,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* limitations under the License.
*/

import type { Neo4jDatabaseInfo } from "../../../classes/Neo4jDatabaseInfo";
import type { PointField } from "../../../types";
import Cypher from "@neo4j/cypher-builder";

Expand All @@ -27,15 +26,13 @@ export function createPointComparisonOperation({
propertyRefOrCoalesce,
param,
pointField,
neo4jDatabaseInfo,
}: {
operator: string | undefined;
propertyRefOrCoalesce: Cypher.Property | Cypher.Function | Cypher.Variable;
param: Cypher.Param | Cypher.Property;
pointField: PointField;
neo4jDatabaseInfo: Neo4jDatabaseInfo;
}): Cypher.ComparisonOp {
const pointDistance = createPointDistanceExpression(propertyRefOrCoalesce, param, neo4jDatabaseInfo);
const pointDistance = createPointDistanceExpression(propertyRefOrCoalesce, param);
const distanceRef = param.property("distance");

switch (operator || "EQ") {
Expand Down Expand Up @@ -77,14 +74,7 @@ function createPointListComprehension(param: Cypher.Param | Cypher.Property): Cy
return new Cypher.ListComprehension(comprehensionVar, param).map(mapPoint);
}

function createPointDistanceExpression(
property: Cypher.Expr,
param: Cypher.Param | Cypher.Property,
neo4jDatabaseInfo: Neo4jDatabaseInfo
): Cypher.Function {
function createPointDistanceExpression(property: Cypher.Expr, param: Cypher.Param | Cypher.Property): Cypher.Function {
const nestedPointRef = param.property("point");
if (neo4jDatabaseInfo.gte("4.4")) {
return Cypher.pointDistance(property, Cypher.point(nestedPointRef));
}
return Cypher.distance(property, Cypher.point(nestedPointRef));
return Cypher.pointDistance(property, Cypher.point(nestedPointRef));
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import type { Context, PredicateReturn } from "../../../types";
import Cypher from "@neo4j/cypher-builder";
import type { GraphElement, Neo4jDatabaseInfo } from "../../../classes";
import type { GraphElement } from "../../../classes";
import { Node } from "../../../classes";
import type { WhereRegexGroups } from "../utils";
import { whereRegEx } from "../utils";
Expand Down Expand Up @@ -168,8 +168,6 @@ export function createPropertyWhere({
operator,
durationField,
pointField,
// Casting because this is definitely assigned in the wrapper
neo4jDatabaseInfo: context.neo4jDatabaseInfo as Neo4jDatabaseInfo,
});
if (isNot) {
return {
Expand Down
3 changes: 2 additions & 1 deletion packages/graphql/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import type { Directive } from "graphql-compose";
import type { ResolveTree } from "graphql-parse-resolve-info";
import type { JWTVerifyOptions, RemoteJWKSetOptions } from "jose";
import type { Integer } from "neo4j-driver";
import type { Node, Relationship } from "../classes";
import type { Neo4jDatabaseInfo, Node, Relationship } from "../classes";
import type { Executor } from "../classes/Executor";
import type { RelationshipNestedOperationsOption, RelationshipQueryDirectionOption } from "../constants";
import type { Neo4jGraphQLSchemaModel } from "../schema-model/Neo4jGraphQLSchemaModel";
Expand Down Expand Up @@ -61,6 +61,7 @@ export interface Context extends Neo4jGraphQLContext {
executor: Executor;
extensions?: Record<string, any>;
authorization: AuthorizationContext;
neo4jDatabaseInfo?: Neo4jDatabaseInfo;
[k: string]: any;
}

Expand Down
5 changes: 0 additions & 5 deletions packages/graphql/src/types/neo4j-graphql-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import type { Driver, Session, Transaction } from "neo4j-driver";
import type { CypherQueryOptions, DriverConfig, RequestLike } from ".";
import type { Neo4jDatabaseInfo } from "../classes";
import type { JWTPayload } from "jose";

export interface Neo4jGraphQLContext {
Expand Down Expand Up @@ -49,10 +48,6 @@ export interface Neo4jGraphQLContext {
* ```
*/
jwt?: JWTPayload;
/**
* @deprecated This property will be removed in 4.0.0.
*/
neo4jDatabaseInfo?: Neo4jDatabaseInfo;
/**
* Configures which {@link https://neo4j.com/docs/cypher-manual/current/query-tuning/query-options/ | Cypher query options}
* when executing the translated query.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
import type { Driver } from "neo4j-driver";
import type { Response } from "supertest";
import supertest from "supertest";
import { Neo4jDatabaseInfo, Neo4jGraphQL } from "../../../src/";
import { Neo4jGraphQL } from "../../../src/";
import { UniqueType } from "../../utils/graphql-types";
import type { TestGraphQLServer } from "../setup/apollo-server";
import { ApolloTestServer } from "../setup/apollo-server";
import Neo4j from "../setup/neo4j";
import { Neo4jDatabaseInfo } from "../../../src/classes";

describe("Create with specific neo4jDatabaseInfo set correctly", () => {
let neo4j: Neo4j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function translateQuery(
}
): Promise<{ cypher: string; params: Record<string, any> }> {
const driverBuilder = new DriverBuilder();
const neo4jDatabaseInfo = new Neo4jDatabaseInfo(options?.neo4jVersion ?? "4.3");
const neo4jDatabaseInfo = new Neo4jDatabaseInfo(options?.neo4jVersion ?? "4.4");
let contextValue: Record<string, any> = { driver: driverBuilder.instance(), neo4jDatabaseInfo };
if (options?.req) {
contextValue.req = options.req;
Expand Down
Loading