Skip to content
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

Use relationship alias for this in directive on rich relationship #246

Merged
merged 7 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ open class ProjectionBase(
val cypherDirective = fieldDefinition.cypherDirective()
val isObjectField = fieldDefinition.type.inner() is GraphQLFieldsContainer
if (cypherDirective != null) {
val query = cypherDirective(field.contextualize(variable), fieldDefinition, field, cypherDirective, propertyContainer.requiredSymbolicName)
val query = cypherDirective(field.contextualize(variable), fieldDefinition, field, cypherDirective, variable)
projections += if (isObjectField && !cypherDirective.passThrough) {
projectListComprehension(variable, field, fieldDefinition, env, query, variableSuffix)
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
:toc:

= Cypher Directive Computing Relationship Type To Field Test

== Schema

[source,graphql,schema=true]
----
type Role @relation(name:"ACTED_IN", from:"actor", to:"movie") {
actor: Person
movie: Movie
type: String @cypher(statement:"""
RETURN type(this)
""")
}

type Person {
name: String
born: Int
roles: [Role]
}

type Movie {
title: String
released: Int
characters: [Role]
}

----

== Queries

=== Simple Cypher Directive on Field

.GraphQL-Query
[source,graphql]
----
query {
person {
roles {
type
}
}
}
----

.Cypher Params
[source,json]
----
{}
----

.Cypher
[source,cypher]
----
MATCH (person:Person)
RETURN person {
roles: [(person)-[personRoles:ACTED_IN]->(personRolesMovie:Movie) | personRoles {
type: apoc.cypher.runFirstColumnSingle('WITH $this AS this RETURN type(this)', {
this: personRoles
})
}]
} AS person
----