-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove run first column #2769
Remove run first column #2769
Changes from 9 commits
78cfee4
0ce4faf
63818ae
4dc75d6
a75e607
e36b235
b048db9
5008aa7
d7368df
e5b53a5
f2bd09c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,7 +182,7 @@ describe("makeAugmentedSchema", () => { | |
} | ||
|
||
type Query { | ||
movies: [Movie!]! @cypher(statement: "") | ||
movies: [Movie!]! @cypher(statement: "RETURN 5 as a", columnName: "a") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The examples in this file upset me, I really wish there was a way we could have Cypher queries like this without the aliasing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, but none we could find :( |
||
} | ||
`; | ||
|
||
|
@@ -225,7 +225,7 @@ describe("makeAugmentedSchema", () => { | |
name: String | ||
} | ||
|
||
interface ActedIn @cypher(statement: "RETURN rand()") { | ||
interface ActedIn @cypher(statement: "RETURN rand() as rand", columnName: "rand") { | ||
screenTime: Int | ||
} | ||
`; | ||
|
@@ -282,7 +282,7 @@ describe("makeAugmentedSchema", () => { | |
} | ||
|
||
interface ActedIn { | ||
id: ID @cypher(statement: "RETURN id(this)") | ||
id: ID @cypher(statement: "RETURN id(this) as id", columnName: "id") | ||
roles: [String] | ||
} | ||
`; | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -171,6 +171,7 @@ describe("validateDocument", () => { | |||||
post.id = randomUUID() | ||||||
RETURN post | ||||||
""" | ||||||
columnName: "post" | ||||||
) | ||||||
} | ||||||
|
||||||
|
@@ -277,6 +278,7 @@ describe("validateDocument", () => { | |||||
s.salaryReviewDate = salary.salaryReviewDate | ||||||
RETURN s | ||||||
""" | ||||||
columnName: "s" | ||||||
) | ||||||
|
||||||
mergeEmploymentRecords(employmentRecords: [EmpRecord]): [EmploymentRecord] | ||||||
|
@@ -303,6 +305,7 @@ describe("validateDocument", () => { | |||||
MERGE (er)-[:PAYS_SALARY]->(s) | ||||||
RETURN er | ||||||
""" | ||||||
columnName: "er" | ||||||
) | ||||||
} | ||||||
`; | ||||||
|
@@ -319,7 +322,7 @@ describe("validateDocument", () => { | |||||
} | ||||||
|
||||||
type Query { | ||||||
nodes: [Test] @cypher(statement: "") | ||||||
nodes: [Test] @cypher(statement: "", columnName: "") | ||||||
} | ||||||
`; | ||||||
|
||||||
|
@@ -374,10 +377,15 @@ describe("validateDocument", () => { | |||||
} | ||||||
|
||||||
extend type Order { | ||||||
subTotal: Float @cypher(statement: "MATCH (this)-[:CONTAINS]->(b:Book) RETURN sum(b.price)") | ||||||
subTotal: Float | ||||||
@cypher( | ||||||
statement: "MATCH (this)-[:CONTAINS]->(b:Book) RETURN sum(b.price) as result" | ||||||
columnName: "result" | ||||||
) | ||||||
shippingCost: Float | ||||||
@cypher( | ||||||
statement: "MATCH (this)-[:SHIPS_TO]->(a:Address) RETURN round(0.01 * distance(a.location, Point({latitude: 40.7128, longitude: -74.0060})) / 1000, 2)" | ||||||
statement: "MATCH (this)-[:SHIPS_TO]->(a:Address) RETURN round(0.01 * distance(a.location, Point({latitude: 40.7128, longitude: -74.0060})) / 1000, 2) as result" | ||||||
columnName: "resul" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
) | ||||||
estimatedDelivery: DateTime @customResolver | ||||||
} | ||||||
|
@@ -389,6 +397,7 @@ describe("validateDocument", () => { | |||||
recommended(limit: Int = 3): [Book] | ||||||
@cypher( | ||||||
statement: "MATCH (this)-[:PLACED]->(:Order)-[:CONTAINS]->(:Book)<-[:CONTAINS]-(:Order)<-[:PLACED]-(c:Customer) MATCH (c)-[:PLACED]->(:Order)-[:CONTAINS]->(rec:Book) WHERE NOT exists((this)-[:PLACED]->(:Order)-[:CONTAINS]->(rec)) RETURN rec LIMIT $limit" | ||||||
columnName: "rec" | ||||||
) | ||||||
} | ||||||
|
||||||
|
@@ -402,6 +411,7 @@ describe("validateDocument", () => { | |||||
currentWeather: Weather | ||||||
@cypher( | ||||||
statement: "CALL apoc.load.json('https://www.7timer.info/bin/civil.php?lon=' + this.location.longitude + '&lat=' + this.location.latitude + '&ac=0&unit=metric&output=json&tzshift=0') YIELD value WITH value.dataseries[0] as weather RETURN {temperature: weather.temp2m, windSpeed: weather.wind10m.speed, windDirection: weather.wind10m.direction, precipitation: weather.prec_type, summary: weather.weather} AS conditions" | ||||||
columnName: "condition" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
) | ||||||
} | ||||||
|
||||||
|
@@ -435,6 +445,7 @@ describe("validateDocument", () => { | |||||
ORDER BY jaccard DESC | ||||||
RETURN b LIMIT 1 | ||||||
""" | ||||||
columnName: "jaccard" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch! |
||||||
) | ||||||
} | ||||||
|
||||||
|
@@ -467,6 +478,7 @@ describe("validateDocument", () => { | |||||
MERGE (t)-[:ABOUT]->(s) | ||||||
RETURN s | ||||||
""" | ||||||
columnName: "s" | ||||||
) | ||||||
} | ||||||
|
||||||
|
@@ -477,6 +489,7 @@ describe("validateDocument", () => { | |||||
CALL db.index.fulltext.queryNodes('bookIndex', $searchString+'~') | ||||||
YIELD node RETURN node | ||||||
""" | ||||||
columnName: "node" | ||||||
) | ||||||
} | ||||||
`; | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -158,18 +158,10 @@ export function translateTopLevelCypher({ | |||||
const apocParamsStr = `{${apocParams.strs.length ? `${apocParams.strs.join(", ")}` : ""}}`; | ||||||
|
||||||
if (type === "Query") { | ||||||
if (field.columnName) { | ||||||
const experimentalCypherStatement = createCypherDirectiveSubquery({ | ||||||
field, | ||||||
}); | ||||||
cypherStrs.push(...experimentalCypherStatement); | ||||||
} else { | ||||||
const legacyCypherStatement = createCypherDirectiveApocProcedure({ | ||||||
field, | ||||||
apocParams: apocParamsStr, | ||||||
}); | ||||||
cypherStrs.push(...legacyCypherStatement); | ||||||
} | ||||||
const experimentalCypherStatement = createCypherDirectiveSubquery({ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This probably shouldn't be called experimental anymore
Suggested change
|
||||||
field, | ||||||
}); | ||||||
cypherStrs.push(...experimentalCypherStatement); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} else { | ||||||
cypherStrs.push(` | ||||||
CALL apoc.cypher.doIt("${statement}", ${apocParamsStr}) YIELD value | ||||||
|
@@ -207,27 +199,6 @@ export function translateTopLevelCypher({ | |||||
}).build(); | ||||||
} | ||||||
|
||||||
function createCypherDirectiveApocProcedure({ | ||||||
field, | ||||||
apocParams, | ||||||
}: { | ||||||
field: CypherField; | ||||||
apocParams: string; | ||||||
}): string[] { | ||||||
const isArray = field.typeMeta.array; | ||||||
const expectMultipleValues = !field.isScalar && !field.isEnum && isArray; | ||||||
const cypherStrs: string[] = []; | ||||||
|
||||||
if (expectMultipleValues) { | ||||||
cypherStrs.push(`WITH apoc.cypher.runFirstColumnMany("${field.statement}", ${apocParams}) as x`); | ||||||
} else { | ||||||
cypherStrs.push(`WITH apoc.cypher.runFirstColumnSingle("${field.statement}", ${apocParams}) as x`); | ||||||
} | ||||||
|
||||||
cypherStrs.push("UNWIND x as this\nWITH this"); | ||||||
return cypherStrs; | ||||||
} | ||||||
|
||||||
function createCypherDirectiveSubquery({ field }: { field: CypherField }): string[] { | ||||||
const cypherStrs: string[] = []; | ||||||
cypherStrs.push("CALL {", field.statement, "}"); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳