Skip to content

Commit 537dce6

Browse files
authored
Merge branch '4.0.0' into chore/cypher-query-options
2 parents 4c6eb3c + 170a895 commit 537dce6

File tree

12 files changed

+15
-290
lines changed

12 files changed

+15
-290
lines changed

.changeset/poor-fans-smile.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@neo4j/graphql": major
3+
---
4+
5+
`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

docs/modules/ROOT/pages/reference/driver-configuration.adoc

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -218,43 +218,6 @@ await startStandaloneServer(server, {
218218
});
219219
----
220220

221-
== Specifying Neo4j version
222-
223-
When a connection is established, the library automatically detect the version of the Neo4j instance connected.
224-
The version will be then stored and used for the following queries.
225-
It is also possible to specify manually the Neo4j version in the Context.
226-
227-
=== Context
228-
229-
[source, javascript, indent=0]
230-
----
231-
import { ApolloServer } from '@apollo/server';
232-
import { startStandaloneServer } from '@apollo/server/standalone';
233-
import { Neo4jDatabaseInfo, Neo4jGraphQL } from "@neo4j/graphql";
234-
import neo4j from "neo4j-driver";
235-
236-
const typeDefs = `#graphql
237-
type User {
238-
name: String
239-
}
240-
`;
241-
242-
const driver = neo4j.driver(
243-
"bolt://localhost:7687",
244-
neo4j.auth.basic("neo4j", "password")
245-
);
246-
247-
const neoSchema = new Neo4jGraphQL({ typeDefs, driver });
248-
249-
const server = new ApolloServer({
250-
schema: await neoSchema.getSchema(),
251-
});
252-
253-
await startStandaloneServer(server, {
254-
context: async ({ req }) => ({ req, neo4jDatabaseInfo: new Neo4jDatabaseInfo("4.4") }),
255-
});
256-
----
257-
258221
[[driver-configuration-bookmarks]]
259222
== Specifying Neo4j Bookmarks
260223

packages/graphql/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { CartesianPoint } from "./graphql/objects/CartesianPoint";
2121
import { Point } from "./graphql/objects/Point";
2222

2323
export {
24-
Neo4jDatabaseInfo,
2524
Neo4jGraphQL,
2625
Neo4jGraphQLAuthenticationError,
2726
Neo4jGraphQLConstructor,

packages/graphql/src/translate/create-aggregate-where-and-params.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
import Cypher from "@neo4j/cypher-builder";
21-
import type { Neo4jDatabaseInfo, Node, Relationship } from "../classes";
21+
import type { Node, Relationship } from "../classes";
2222
import type { RelationField, Context, GraphQLWhereArg, PredicateReturn } from "../types";
2323
import type { AggregationFieldRegexGroups } from "./where/utils";
2424
import { aggregationFieldRegEx, whereRegEx } from "./where/utils";
@@ -256,8 +256,6 @@ function createEntityOperation(
256256
param: paramName,
257257
durationField,
258258
pointField,
259-
// Casting because this is definitely assigned in the wrapper
260-
neo4jDatabaseInfo: context.neo4jDatabaseInfo as Neo4jDatabaseInfo,
261259
});
262260
const dbFieldName = mapToDbProperty(refNodeOrRelation, fieldName);
263261
const collectedProperty =

packages/graphql/src/translate/where/property-operations/create-comparison-operation.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
* limitations under the License.
1818
*/
1919

20-
import type { Neo4jDatabaseInfo } from "../../../classes/Neo4jDatabaseInfo";
2120
import type { PointField, PrimitiveField } from "../../../types";
2221
import Cypher from "@neo4j/cypher-builder";
2322
import { createPointComparisonOperation } from "./create-point-comparison-operation";
@@ -29,14 +28,12 @@ export function createComparisonOperation({
2928
param,
3029
durationField,
3130
pointField,
32-
neo4jDatabaseInfo,
3331
}: {
3432
operator: string | undefined;
3533
propertyRefOrCoalesce: Cypher.Property | Cypher.Function | Cypher.Variable;
3634
param: Cypher.Param | Cypher.Property | Cypher.Function;
3735
durationField: PrimitiveField | undefined;
3836
pointField: PointField | undefined;
39-
neo4jDatabaseInfo: Neo4jDatabaseInfo;
4037
}): Cypher.ComparisonOp {
4138
// TODO: consider if this conditional is the correct solution - should we make the function compatible?
4239
if (!(param instanceof Cypher.Function) && pointField) {
@@ -45,7 +42,6 @@ export function createComparisonOperation({
4542
propertyRefOrCoalesce,
4643
param,
4744
pointField,
48-
neo4jDatabaseInfo,
4945
});
5046
}
5147

packages/graphql/src/translate/where/property-operations/create-point-comparison-operation.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
* limitations under the License.
1818
*/
1919

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

@@ -27,15 +26,13 @@ export function createPointComparisonOperation({
2726
propertyRefOrCoalesce,
2827
param,
2928
pointField,
30-
neo4jDatabaseInfo,
3129
}: {
3230
operator: string | undefined;
3331
propertyRefOrCoalesce: Cypher.Property | Cypher.Function | Cypher.Variable;
3432
param: Cypher.Param | Cypher.Property;
3533
pointField: PointField;
36-
neo4jDatabaseInfo: Neo4jDatabaseInfo;
3734
}): Cypher.ComparisonOp {
38-
const pointDistance = createPointDistanceExpression(propertyRefOrCoalesce, param, neo4jDatabaseInfo);
35+
const pointDistance = createPointDistanceExpression(propertyRefOrCoalesce, param);
3936
const distanceRef = param.property("distance");
4037

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

80-
function createPointDistanceExpression(
81-
property: Cypher.Expr,
82-
param: Cypher.Param | Cypher.Property,
83-
neo4jDatabaseInfo: Neo4jDatabaseInfo
84-
): Cypher.Function {
77+
function createPointDistanceExpression(property: Cypher.Expr, param: Cypher.Param | Cypher.Property): Cypher.Function {
8578
const nestedPointRef = param.property("point");
86-
if (neo4jDatabaseInfo.gte("4.4")) {
87-
return Cypher.pointDistance(property, Cypher.point(nestedPointRef));
88-
}
89-
return Cypher.distance(property, Cypher.point(nestedPointRef));
79+
return Cypher.pointDistance(property, Cypher.point(nestedPointRef));
9080
}

packages/graphql/src/translate/where/property-operations/create-property-where.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import type { Context, PredicateReturn } from "../../../types";
2121
import Cypher from "@neo4j/cypher-builder";
22-
import type { GraphElement, Neo4jDatabaseInfo } from "../../../classes";
22+
import type { GraphElement } from "../../../classes";
2323
import { Node } from "../../../classes";
2424
import type { WhereRegexGroups } from "../utils";
2525
import { whereRegEx } from "../utils";
@@ -168,8 +168,6 @@ export function createPropertyWhere({
168168
operator,
169169
durationField,
170170
pointField,
171-
// Casting because this is definitely assigned in the wrapper
172-
neo4jDatabaseInfo: context.neo4jDatabaseInfo as Neo4jDatabaseInfo,
173171
});
174172
if (isNot) {
175173
return {

packages/graphql/src/types/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import type { Directive } from "graphql-compose";
2424
import type { ResolveTree } from "graphql-parse-resolve-info";
2525
import type { JWTVerifyOptions, RemoteJWKSetOptions } from "jose";
2626
import type { Integer } from "neo4j-driver";
27-
import type { Node, Relationship } from "../classes";
27+
import type { Neo4jDatabaseInfo, Node, Relationship } from "../classes";
2828
import type { Executor } from "../classes/Executor";
2929
import type { RelationshipNestedOperationsOption, RelationshipQueryDirectionOption } from "../constants";
3030
import type { Neo4jGraphQLSchemaModel } from "../schema-model/Neo4jGraphQLSchemaModel";
@@ -61,6 +61,7 @@ export interface Context extends Neo4jGraphQLContext {
6161
executor: Executor;
6262
extensions?: Record<string, any>;
6363
authorization: AuthorizationContext;
64+
neo4jDatabaseInfo?: Neo4jDatabaseInfo;
6465
[k: string]: any;
6566
}
6667

packages/graphql/src/types/neo4j-graphql-context.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

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

2524
export interface Neo4jGraphQLContext {
@@ -54,24 +53,6 @@ export interface Neo4jGraphQLContext {
5453
* ```
5554
*/
5655
jwt?: JWTPayload;
57-
/**
58-
* @deprecated This property will be removed in 4.0.0.
59-
*/
60-
neo4jDatabaseInfo?: Neo4jDatabaseInfo;
61-
/**
62-
* HTTP request object containing authorization header for use in authentication and authorization.
63-
* Alias for {@link request}.
64-
*
65-
* @deprecated Will be removed in 4.0.0 alongside `@auth` - use the {@link token} property to provide the bearer token for the new authorization features.
66-
*/
67-
req?: RequestLike;
68-
/**
69-
* HTTP request object containing authorization header for use in authentication and authorization.
70-
* Alias for {@link req}.
71-
*
72-
* @deprecated Will be removed in 4.0.0 alongside `@auth` - use the {@link token} property to provide the bearer token for the new authorization features.
73-
*/
74-
request?: RequestLike;
7556
/**
7657
* The bearer token to be decoded/verified for use in authentication and authorization.
7758
* Normally found in the Authorization HTTP header. Can be provided with or without authentication scheme.

packages/graphql/tests/e2e/neo4jgraphql/neo4j-database-info.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
import type { Driver } from "neo4j-driver";
2121
import type { Response } from "supertest";
2222
import supertest from "supertest";
23-
import { Neo4jDatabaseInfo, Neo4jGraphQL } from "../../../src/";
23+
import { Neo4jGraphQL } from "../../../src/";
2424
import { UniqueType } from "../../utils/graphql-types";
2525
import type { TestGraphQLServer } from "../setup/apollo-server";
2626
import { ApolloTestServer } from "../setup/apollo-server";
2727
import Neo4j from "../setup/neo4j";
28+
import { Neo4jDatabaseInfo } from "../../../src/classes";
2829

2930
describe("Create with specific neo4jDatabaseInfo set correctly", () => {
3031
let neo4j: Neo4j;

0 commit comments

Comments
 (0)