19
19
20
20
import Cypher from "@neo4j/cypher-builder" ;
21
21
import type { PredicateReturn } from "../../../types" ;
22
+ import type { Neo4jGraphQLTranslationContext } from "../../../types/neo4j-graphql-translation-context" ;
22
23
import { compileCypher } from "../../../utils/compile-cypher" ;
24
+ import { buildClause } from "../../utils/build-clause" ;
23
25
24
26
type CompiledPredicateReturn = {
25
27
cypher : string ;
@@ -33,10 +35,15 @@ type CompiledPredicateReturn = {
33
35
* The subqueries contain variables required by the predicate, and if they are not compiled with the same
34
36
* environment, the predicate will be referring to non-existent variables and will re-assign variable from the subqueries.
35
37
*/
36
- export function compilePredicateReturn (
37
- predicateReturn : PredicateReturn ,
38
- indexPrefix ?: string
39
- ) : CompiledPredicateReturn {
38
+ export function compilePredicateReturn ( {
39
+ predicateReturn,
40
+ indexPrefix,
41
+ context,
42
+ } : {
43
+ predicateReturn : PredicateReturn ;
44
+ indexPrefix : string | undefined ;
45
+ context : Neo4jGraphQLTranslationContext ;
46
+ } ) : CompiledPredicateReturn {
40
47
const result : CompiledPredicateReturn = { cypher : "" , params : { } } ;
41
48
42
49
const { predicate, preComputedSubqueries } = predicateReturn ;
@@ -52,7 +59,10 @@ export function compilePredicateReturn(
52
59
}
53
60
return predicateStr ;
54
61
} ) ;
55
- const { cypher, params } = predicateCypher . build ( { prefix : `authorization_${ indexPrefix || "" } ` } ) ;
62
+ const { cypher, params } = buildClause ( predicateCypher , {
63
+ context,
64
+ prefix : `authorization_${ indexPrefix || "" } ` ,
65
+ } ) ;
56
66
result . cypher = cypher ;
57
67
result . params = params ;
58
68
result . subqueries = subqueries ;
0 commit comments