-
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
Conversation
🦋 Changeset detectedLatest commit: f2bd09c The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Performance Report
🟥 - Performance worsened (dbHits) Show Full Table
Old Schema Generation: 35.521s |
I've not had a chance to properly look over this yet but a general observation is that I think this could do with some updates to the documentation for the The 4.0.0 migration guide also probably needs an update to make clear that at the point this is released, |
Yeah, these will be added as a separate PR to reduce the size of these for review |
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.
This is looking good, especially the performance improvement! Just a couple of typos in the updated tests and some edge cases that I'm not clear on the expected behaviour (mainly because I didn't see the first stage of this) and could possibly benefit from tests
"apoc.cypher.runFirstColumnMany", | ||
"apoc.date.convertFormat", | ||
]; | ||
export const REQUIRED_APOC_FUNCTIONS = ["apoc.util.validatePredicate", "apoc.date.convertFormat"]; |
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.
🥳
@@ -79,7 +79,8 @@ describe("cypher", () => { | |||
statement: """ | |||
MATCH (m:${Movie} {title: $title}) | |||
RETURN m | |||
""" | |||
""", | |||
columnName: "m" |
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.
I wouldn't say these are blockers but it'd be interesting to see what the expected behaviour/error is if columnName
is not provided now.
It'd also be interesting to see the behaviour if the wrong column name is provided.
Are there any tests that show either of these cases?
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.
columnName
is now be a mandatory field in the directive definition, so it will literally fail type definition validation if it isn't passed in.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
columnName: "resul" | |
columnName: "result" |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
columnName: "condition" | |
columnName: "conditions" |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
columnName: "jaccard" | |
columnName: "b" |
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.
good catch!
}); | ||
cypherStrs.push(...legacyCypherStatement); | ||
} | ||
const experimentalCypherStatement = createCypherDirectiveSubquery({ |
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.
This probably shouldn't be called experimental anymore
const experimentalCypherStatement = createCypherDirectiveSubquery({ | |
const cypherStatement = createCypherDirectiveSubquery({ |
const experimentalCypherStatement = createCypherDirectiveSubquery({ | ||
field, | ||
}); | ||
cypherStrs.push(...experimentalCypherStatement); |
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.
cypherStrs.push(...experimentalCypherStatement); | |
cypherStrs.push(...cypherStatement); |
@@ -79,7 +79,8 @@ describe("cypher", () => { | |||
statement: """ | |||
MATCH (m:${Movie} {title: $title}) | |||
RETURN m | |||
""" | |||
""", | |||
columnName: "m" | |||
) |
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.
Also not a blocker but I'm not clear what should happen if a user tried to return multiple columns in their cypher statement. Are there any tests for this?
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.
it would get ignored, as columnName is used in with
@@ -1,115 +0,0 @@ | |||
/* |
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.
Why has this been deleted? Is it not possible to use columnName
in this test?
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.
This test is no longer relevant, as this is only caused when a cypher query does not return anything, which is no longer supported
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.
The changes are good! You are going to have to remind me, why is it that we decided against running EXPLAIN
on the queries? I'm still really not 100% a fan of this approach, it feels somewhat like we're pinning our shortcomings onto our users.
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but none we could find :(
answering to you @darrellwarde
I have the same concerns, and I feel that we could even keep providing a version without columnName using APOC, even if not recommended. Another alternative could be trying to do some parsing if columnName is not provided. Even if this alternative does not work for all cases, columnName will always be available there to custom configure. I'm happy to keep this PR open a bit longer if we want to keep this discussion going before merging |
Description
Removes
runFirstColumn
from the@cypher
directive, forcing the directive to be used with thecolumnName
option.Updates all tests to comply with this new requirement
Complexity
Complexity: Medium