Skip to content

Commit

Permalink
Add cypher version to generated queries
Browse files Browse the repository at this point in the history
  • Loading branch information
angrykoala committed Jan 23, 2025
1 parent 281ea46 commit da0447d
Show file tree
Hide file tree
Showing 323 changed files with 2,913 additions and 1,483 deletions.
5 changes: 5 additions & 0 deletions .changeset/lucky-panthers-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@neo4j/graphql": patch
---

Add `CYPHER 5` to generated queries to ensure the correct cypher version is used in Aura
4 changes: 3 additions & 1 deletion packages/graphql/src/translate/translate-aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@ export function translateAggregate({
const queryAST = queryASTFactory.createQueryAST({ resolveTree, entityAdapter, context });
debug(queryAST.print());
const clause = queryAST.buildNew(context);
return clause.build();
return clause.build({
cypherVersion: "5",
});
}
2 changes: 1 addition & 1 deletion packages/graphql/src/translate/translate-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default async function translateCreate({
];
});

const createQueryCypher = createQuery.build({ prefix: "create_" });
const createQueryCypher = createQuery.build({ prefix: "create_", cypherVersion: "5" });
const { cypher, params: resolvedCallbacks } = await callbackBucket.resolveCallbacksAndFilterCypher({
cypher: createQueryCypher.cypher,
});
Expand Down
4 changes: 3 additions & 1 deletion packages/graphql/src/translate/translate-delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ function translateUsingQueryAST({
});
debug(operationsTree.print());
const clause = operationsTree.build(context, varName);
return clause.build();
return clause.build({
cypherVersion: "5",
});
}
export function translateDelete({
context,
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/src/translate/translate-read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ export function translateRead({
});
debug(operationsTree.print());
const clause = operationsTree.build(context, varName);
return clause.build();
return clause.build({ cypherVersion: "5" });
}
10 changes: 6 additions & 4 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 All @@ -46,5 +46,7 @@ export function translateResolveReference({
});
debug(operationsTree.print());
const clause = operationsTree.build(context, "this");
return clause.build();
return clause.build({
cypherVersion: "5",
});
}
4 changes: 3 additions & 1 deletion packages/graphql/src/translate/translate-top-level-cypher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,7 @@ export function translateTopLevelCypher({
const projectionStatements = queryASTResult.clauses.length
? Cypher.utils.concat(...queryASTResult.clauses)
: new Cypher.Return(new Cypher.Literal("Query cannot conclude with CALL"));
return projectionStatements.build();
return projectionStatements.build({
cypherVersion: "5",
});
}
2 changes: 1 addition & 1 deletion packages/graphql/src/translate/translate-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ export default async function translateUpdate({
];
});

const cypherResult = updateQuery.build({ prefix: "update_" });
const cypherResult = updateQuery.build({ prefix: "update_", cypherVersion: "5" });
const { cypher, params: resolvedCallbacks } = await callbackBucket.resolveCallbacksAndFilterCypher({
cypher: cypherResult.cypher,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/src/translate/unwind-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ export default function unwindCreate({

const clauses = queryAST.build(context);

return clauses.build({ prefix: "create_" });
return clauses.build({ prefix: "create_", cypherVersion: "5" });
}
Loading

0 comments on commit da0447d

Please sign in to comment.