Table of Contents
type Person {
name: String
label: String! @cypher(statement: "RETURN toLower(this.name) as label")
nullable: String @cypher(statement: "RETURN null")
}
type Order {
sid: ID!
name: String
description: String
date: Int
position: [OrderPosition] @relation(name:"PART_OF",direction:IN)
}
type OrderPosition {
amount: Int
order: Order @relation(name:"PART_OF")
sid: ID!
}
schema {
mutation: MutationType
query: QueryType
}
type QueryType {
Person(name:String) : Person @cypher(statement:"MATCH (p:Person { name:{name} }) RETURN p")
getOrderPosition(sid:ID!) : [OrderPosition] @cypher(statement:"MATCH (op:OrderPosition {sid: {sid}}) RETURN op")
}
type MutationType {
createPerson(name:String) : Person @cypher(statement:"CREATE (p:Person { name: \"Test\"+{name} }) RETURN p")
setOrderPositionAmount(sid:ID!, amount:Int) : [OrderPosition] @cypher(statement:"MATCH (op:OrderPosition {sid:{sid}}) SET op.amount = {amount} RETURN op")
}
GraphQL-Query
mutation { createPerson(name:"Jill") {name} }
GraphQL-Response
{
"createPerson" : {
"name" : "TestJill"
}
}
Cypher Params
{
"createPersonName" : "Jill"
}
Cypher
CALL apoc.cypher.doIt('WITH $name AS name CREATE (p: Person { name: \"Test\"+{ name }}) RETURN p', { name: $createPersonName })
YIELD value
WITH value[head(keys(value))] AS createPerson
RETURN createPerson { .name } AS createPerson
GraphQL-Query
query { Person(name:"Jane") {name} }
GraphQL-Response
{
"Person" : {
"name" : "Jane"
}
}
Cypher Params
{
"personName" : "Jane"
}
Cypher
UNWIND apoc.cypher.runFirstColumnSingle('WITH $name AS name MATCH (p: Person { name: { name } }) RETURN p', { name: $personName }) AS person
RETURN person { .name } AS Person
GraphQL-Query
query { Person(name:"Jane") {name, label} }
GraphQL-Response
{
"Person" : {
"name" : "Jane",
"label" : "jane"
}
}
Cypher Params
{
"personName" : "Jane"
}
Cypher
UNWIND apoc.cypher.runFirstColumnSingle('WITH $name AS name MATCH (p: Person { name: { name } }) RETURN p', { name: $personName }) AS person
RETURN person {
.name,
label: apoc.cypher.runFirstColumnSingle('WITH $this AS this RETURN toLower(this.name) as label', { this: person })
} AS Person
GraphQL-Query
query { Person(name:"Jane") {name, nullable} }
GraphQL-Response
{
"Person" : {
"nullable" : null,
"name" : "Jane"
}
}
Cypher Params
{
"personName" : "Jane"
}
Cypher
UNWIND apoc.cypher.runFirstColumnSingle('WITH $name AS name MATCH (p: Person { name: { name } }) RETURN p', { name: $personName }) AS person
RETURN person {
.name,
nullable: apoc.cypher.runFirstColumnSingle('WITH $this AS this RETURN null', { this: person })
} AS Person