Table of Contents
- Schema
- Queries
- Simple Cypher Directive on Field
- render cypher query directive params args
- render cypher field directive with params defaults
- render cypher query directive
- render cypher mutation directive
- render cypher field directive with params
- render cypher field directive nested
- render cypher query directive params
- render cypher field directive scalar
type Person {
id: ID
name: String @cypher(statement:"RETURN this.name")
age(mult:Int=13) : [Int] @cypher(statement:"RETURN this.age * mult as age")
friends: [Person] @cypher(statement:"MATCH (this)-[:KNOWS]-(o) RETURN o")
}
type Query {
person : [Person]
p2: [Person] @cypher(statement:"MATCH (p:Person) RETURN p")
p3(name:String): Person @cypher(statement:"MATCH (p:Person) WHERE p.name = name RETURN p LIMIT 1")
}
type Mutation {
createPerson(name:String): Person @cypher(statement:"CREATE (p:Person) SET p.name = name RETURN p")
}
schema {
query: Query
mutation: Mutation
}
GraphQL-Query
{ person { name }}
Cypher Params
{}
Cypher
MATCH (person:Person)
RETURN person { name:apoc.cypher.runFirstColumnSingle('WITH $this AS this RETURN this.name', { this:person }) } AS person
GraphQL-Query
query($pname:String) { p3(name:$pname) { id }}
Query variables
{"pname":"foo"}
Cypher params
{"pname":"foo"}
Cypher
UNWIND apoc.cypher.runFirstColumnSingle('WITH $name AS name MATCH (p:Person) WHERE p.name = name RETURN p LIMIT 1', { name:$pname }) AS p3 RETURN p3 { .id } AS p3
GraphQL-Query
{ person { age }}
Query variables
{}
Cypher params
{"personMult":13}
Cypher
MATCH (person:Person) RETURN person { age:apoc.cypher.runFirstColumnMany('WITH $this AS this, $mult AS mult RETURN this.age * mult as age', { this:person, mult:$personMult }) } AS person
GraphQL-Query
{ p2 { id }}
Query variables
{}
Cypher params
{}
Cypher
UNWIND apoc.cypher.runFirstColumnMany('MATCH (p:Person) RETURN p', { }) AS p2 RETURN p2 { .id } AS p2
GraphQL-Query
mutation { person: createPerson(name:"Joe") { id }}
Query variables
{}
Cypher params
{"personName":"Joe"}
Cypher
CALL apoc.cypher.doIt('WITH $name AS name CREATE (p:Person) SET p.name = name RETURN p', { name:$personName }) YIELD value WITH value[head(keys(value))] AS person RETURN person { .id } AS person
GraphQL-Query
{ person { age(mult:25) }}
Query variables
{}
Cypher params
{"personMult":25}
Cypher
MATCH (person:Person) RETURN person { age:apoc.cypher.runFirstColumnMany('WITH $this AS this, $mult AS mult RETURN this.age * mult as age', { this:person, mult:$personMult }) } AS person
GraphQL-Query
{ person { friends { id } }}
Query variables
{}
Cypher params
{}
Cypher
MATCH (person:Person)
RETURN person { friends:[personFriends IN
apoc.cypher.runFirstColumnMany('WITH $this AS this MATCH (this)-[:KNOWS]-(o) RETURN o', { this:person }) | personFriends { .id }] } AS person
GraphQL-Query
{ p3(name:"Jane") { id }}
Query variables
{}
Cypher params
{"p3Name":"Jane"}
Cypher
UNWIND apoc.cypher.runFirstColumnSingle('WITH $name AS name MATCH (p:Person) WHERE p.name = name RETURN p LIMIT 1', { name:$p3Name }) AS p3 RETURN p3 { .id } AS p3