Skip to content

Commit

Permalink
Merge branch 'dev' into feature/sortable-directive
Browse files Browse the repository at this point in the history
  • Loading branch information
darrellwarde authored Feb 28, 2025
2 parents ab8cdfb + 33ca95a commit 61f6685
Show file tree
Hide file tree
Showing 23 changed files with 292 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changesets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: lts/*

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cla-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
repository: neo-technology/whitelist-check
token: ${{ secrets.NEO4J_TEAM_GRAPHQL_PERSONAL_ACCESS_TOKEN }}
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5
with:
python-version: 3
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-markdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: lts/*
- name: Install markdownlint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/performance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

steps:
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: lts/*

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: 18.13.0
cache: yarn
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/reusable-api-library-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: lts/*
cache: yarn
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: lts/*
cache: yarn
Expand All @@ -82,7 +82,7 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: lts/*
cache: yarn
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reusable-aura-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
ref: ${{ inputs.BRANCH || github.ref }}
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: lts/*
cache: yarn
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
steps:
- name: Check out repository code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: lts/*
cache: yarn
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/reusable-codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: lts/*
- name: Initialize CodeQL
uses: github/codeql-action/init@f6091c0113d1dcf9b98e269ee48e8a7e51b7bdd4 # v3
uses: github/codeql-action/init@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3
with:
config-file: ./.github/codeql/codeql-config.yml
languages: javascript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@f6091c0113d1dcf9b98e269ee48e8a7e51b7bdd4 # v3
uses: github/codeql-action/analyze@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3
2 changes: 1 addition & 1 deletion .github/workflows/reusable-federation-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- name: Check out repository code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: lts/*
cache: yarn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Check out repository code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Setting up Node.js with version ${{ matrix.node.name }}
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: ${{ matrix.node.name }}
cache: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-integration-tests-on-prem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
steps:
- name: Check out repository code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: lts/*
cache: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-package-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: 18.13.0
cache: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: lts/*
cache: yarn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dependencies": {
"@apollo/server": "^4.7.0",
"@graphql-tools/wrap": "^10.0.0",
"@neo4j/graphql": "^6.3.0",
"@neo4j/graphql": "^6.3.1",
"graphql": "16.10.0",
"graphql-tag": "^2.12.6",
"neo4j-driver": "^5.8.0"
Expand Down
23 changes: 23 additions & 0 deletions packages/graphql/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# @neo4j/graphql

## 6.3.1

### Patch Changes

- [#5952](https://github.com/neo4j/graphql/pull/5952) [`4e14680`](https://github.com/neo4j/graphql/commit/4e1468076bbd23cdd9156b039de1d03bbc68942c) Thanks [@angrykoala](https://github.com/angrykoala)! - Add `addVersionPrefix` to `cypherQueryOptions` in context to add a Cypher version with `CYPHER` before each query:

```js
{
cypherQueryOptions: {
addVersionPrefix: true,
},
}
```

This prepends all Cypher queries with a `CYPHER [version]` statement:

```cypher
CYPHER 5
MATCH (this:Movie)
WHERE this.title = $param0
RETURN this { .title } AS this
```

## 6.3.0

### Minor Changes
Expand Down
8 changes: 4 additions & 4 deletions packages/graphql/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@neo4j/graphql",
"version": "6.3.0",
"version": "6.3.1",
"description": "A GraphQL to Cypher query execution layer for Neo4j and JavaScript GraphQL implementations",
"keywords": [
"neo4j",
Expand Down Expand Up @@ -60,11 +60,11 @@
"jest": "29.7.0",
"jest-extended": "4.0.2",
"jwks-rsa": "3.1.0",
"koa": "2.15.3",
"koa": "2.15.4",
"koa-jwt": "4.0.4",
"koa-router": "13.0.1",
"mock-jwks": "1.0.10",
"nock": "13.5.6",
"nock": "14.0.0",
"randomstring": "1.3.1",
"rimraf": "6.0.1",
"supertest": "7.0.0",
Expand All @@ -79,7 +79,7 @@
"@graphql-tools/resolvers-composition": "^7.0.0",
"@graphql-tools/schema": "^10.0.0",
"@graphql-tools/utils": "10.6.1",
"@neo4j/cypher-builder": "2.2.1",
"@neo4j/cypher-builder": "2.3.0",
"camelcase": "^6.3.0",
"debug": "^4.3.4",
"dot-prop": "^6.0.1",
Expand Down
38 changes: 29 additions & 9 deletions packages/graphql/src/classes/Executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
} from "../constants";
import { debugCypherAndParams } from "../debug/debug-cypher-and-params";
import type { CypherQueryOptions } from "../types";
import { isInArray } from "../utils/is-in-array";
import {
Neo4jGraphQLAuthenticationError,
Neo4jGraphQLConstraintValidationError,
Expand All @@ -49,6 +50,8 @@ import {

const debug = Debug(DEBUG_EXECUTE);

const SUPPORTED_CYPHER_VERSION = "5";

interface DriverLike {
session(config);
}
Expand Down Expand Up @@ -107,7 +110,6 @@ export class Executor {
}: ExecutorConstructorParam) {
this.executionContext = executionContext;
this.cypherQueryOptions = cypherQueryOptions;
this.cypherQueryOptions = cypherQueryOptions;
this.sessionConfig = sessionConfig;
this.cypherParams = cypherParams;
this.transactionMetadata = transactionMetadata;
Expand Down Expand Up @@ -173,16 +175,34 @@ export class Executor {
return error;
}

private generateQuery(query: string): string {
if (this.cypherQueryOptions && Object.keys(this.cypherQueryOptions).length) {
const cypherQueryOptions = `CYPHER ${Object.entries(this.cypherQueryOptions)
.map(([key, value]) => `${key}=${value}`)
.join(" ")}`;
private addCypherOptionsToQuery(query: string): string {
const cypherVersion = this.getCypherVersionStatement();

const cypherQueryOptions = this.getCypherQueryOptionsStatement();

return `${cypherVersion}${cypherQueryOptions}${query}`;
}

return `${cypherQueryOptions}\n${query}`;
private getCypherVersionStatement(): string {
if (this.cypherQueryOptions?.addVersionPrefix) {
return `CYPHER ${SUPPORTED_CYPHER_VERSION}\n`;
}
return "";
}

return query;
private getCypherQueryOptionsStatement(): string {
const ignoredCypherQueryOptions: Array<keyof CypherQueryOptions> = ["addVersionPrefix"];
const cypherQueryOptions = Object.entries(this.cypherQueryOptions ?? []).filter(([key, _value]) => {
return !isInArray(ignoredCypherQueryOptions, key);
});
if (cypherQueryOptions.length) {
return `CYPHER ${cypherQueryOptions
.map(([key, value]) => {
return `${key}=${value}`;
})
.join(" ")}\n`;
}
return "";
}

private getTransactionConfig(info?: GraphQLResolveInfo): TransactionConfig {
Expand Down Expand Up @@ -276,7 +296,7 @@ export class Executor {
parameters: Record<string, any>,
transaction: Transaction | ManagedTransaction
): Result {
const queryToRun = this.generateQuery(query);
const queryToRun = this.addCypherOptionsToQuery(query);

debugCypherAndParams(debug, queryToRun, parameters);

Expand Down
6 changes: 3 additions & 3 deletions packages/graphql/src/translate/translate-resolve-reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
*/

import type Cypher from "@neo4j/cypher-builder";
import type { Neo4jGraphQLTranslationContext } from "../types/neo4j-graphql-translation-context";
import Debug from "debug";
import { QueryASTFactory } from "./queryAST/factory/QueryASTFactory";
import type { EntityAdapter } from "../schema-model/entity/EntityAdapter";
import { DEBUG_TRANSLATE } from "../constants";
import type { EntityAdapter } from "../schema-model/entity/EntityAdapter";
import type { Neo4jGraphQLTranslationContext } from "../types/neo4j-graphql-translation-context";
import { QueryASTFactory } from "./queryAST/factory/QueryASTFactory";

const debug = Debug(DEBUG_TRANSLATE);

Expand Down
1 change: 1 addition & 0 deletions packages/graphql/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export interface CypherQueryOptions {
operatorEngine?: "default" | "interpreted" | "compiled";
interpretedPipesFallback?: "default" | "disabled" | "whitelisted_plans_only" | "all";
replan?: "default" | "force" | "skip";
addVersionPrefix?: boolean;
}

/** Input field for graphql-compose */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("Subscription global authentication", () => {
let server: TestGraphQLServer;
let wsClient: WebSocketTestClient;

beforeAll(async () => {
beforeEach(async () => {
const neoSchema = await testHelper.initNeo4jGraphQL({
typeDefs,
features: {
Expand All @@ -71,9 +71,6 @@ describe("Subscription global authentication", () => {

afterEach(async () => {
await wsClient.close();
});

afterAll(async () => {
await testHelper.close();
await server.close();
});
Expand Down Expand Up @@ -123,7 +120,7 @@ describe("Subscription global authentication", () => {
let server: TestGraphQLServer;
let wsClient: WebSocketTestClient;

beforeAll(async () => {
beforeEach(async () => {
const neoSchema = await testHelper.initNeo4jGraphQL({
typeDefs,
features: {
Expand All @@ -146,9 +143,6 @@ describe("Subscription global authentication", () => {

afterEach(async () => {
await wsClient.close();
});

afterAll(async () => {
await testHelper.close();
await server.close();
});
Expand Down Expand Up @@ -198,7 +192,7 @@ describe("Subscription global authentication", () => {
let server: TestGraphQLServer;
let wsClient: WebSocketTestClient;

beforeAll(async () => {
beforeEach(async () => {
const neoSchema = await testHelper.initNeo4jGraphQL({
typeDefs,
features: {
Expand All @@ -221,9 +215,6 @@ describe("Subscription global authentication", () => {

afterEach(async () => {
await wsClient.close();
});

afterAll(async () => {
await testHelper.close();
await server.close();
});
Expand Down
Loading

0 comments on commit 61f6685

Please sign in to comment.