-
Notifications
You must be signed in to change notification settings - Fork 49
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
Make use of sub-queries, to get rid of most apoc calls. #222
Conversation
only thing left is updating to ne next release of the neo4j-cypher-dsl |
7e59840
to
e3422ff
Compare
e3422ff
to
a5c24f5
Compare
Feel free to ping me if needed. |
}) YIELD value | ||
WITH value[head(keys(value))] AS createPerson | ||
CALL { | ||
WITH $createPersonName AS name |
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.
we need to watch out here for naming conflicts if we rename to a single/simple name, we should still be able to use parameters in the subqueries
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 see no potential conflict here:
$createPersonName
is defined by the libraryname
is the name of the fields' argument defined by the user
@@ -14,7 +14,7 @@ typealias CypherDSL = org.neo4j.cypherdsl.core.Cypher | |||
|
|||
enum class FieldOperator( | |||
val suffix: String, | |||
val op: String, |
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 is this not a val anymore? shouldn't enums only have immutable fields?
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's not a field anymore it is just used inside the constructor and so used as parameter only.
# Conflicts: # core/pom.xml # core/src/main/kotlin/org/neo4j/graphql/Predicates.kt # core/src/main/kotlin/org/neo4j/graphql/handler/projection/ProjectionBase.kt
@@ -602,7 +602,10 @@ It allows you, without code to *compute field values* using complex queries. | |||
|
|||
You can also write your own, *custom top-level queries and mutations* using Cypher. | |||
|
|||
Arguments on the field are passed to the Cypher statement as parameters. | |||
Arguments on the field are passed to the Cypher statement and can be used by name. They must not be prefixed by `$` since they are no longer parameters. Just use the same name as the fields' argument. |
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.
but then this means it's a breaking change and users will have to rewrite their schemas before they can use this version
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.
We transform old queries with the regex you found earlier and give some warning, so we should be compatible
.referralDate, | ||
referredBy: userReferredByReferredBy { | ||
.name | ||
} | ||
}][0], | ||
referred: [(user)<-[userReferred:REFERRED_BY]-(userReferredUser:User) | userReferred { | ||
} AS userReferredBy LIMIT 1 |
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.
note that if any of those subqueries doesn't return a result, it will cause teh whole query to not emit any results
that's a big difference to how pattern comprehsensions work because they are independent and would just create an empty list instead
probably better WITH ... LIMIT 1 RETURN collect(userReferredByReferredBy) which would then at least return an empty list instead (or one element list)
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.
OR you need to use OPTIONAL MATCH here WHICH RETURNs null rows for each input row if not-matching.
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 think this will otherwise lead to critical bugs
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.
Looks great, thanks so much. Sorry it took so long.
resolves #214