Table of Contents
Schema
type Person {
name: String
label: String! @cypher(statement: "RETURN toLower(this.name)")
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")
}
Schema Configuration
{
"capitalizeQueryFields": true
}
Test Data
CREATE (:Person {name:'Jane'}), (:Person {name:'John'})
GraphQL-Query
mutation { createPerson(name:"Jill") {name} }
GraphQL-Response
{
"createPerson" : {
"name" : "TestJill"
}
}
Cypher Params
{
"createPersonName" : "Jill"
}
Cypher
CALL {
WITH $createPersonName AS name
CREATE (p:Person { name: "Test"+name }) RETURN p AS createPerson LIMIT 1
}
RETURN createPerson {
.name
} AS createPerson
Test Data
CREATE (:Person {name:'Jane'}), (:Person {name:'John'})
GraphQL-Query
query { Person(name:"Jane") {name} }
GraphQL-Response
{
"Person" : {
"name" : "Jane"
}
}
Cypher Params
{
"personName" : "Jane"
}
Cypher
CALL {
WITH $personName AS name
MATCH (p:Person { name: name }) RETURN p AS person LIMIT 1
}
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
CALL {
WITH $personName AS name
MATCH (p:Person { name: name }) RETURN p AS person LIMIT 1
}
CALL {
WITH person
WITH person AS this
RETURN toLower(this.name) AS personLabel LIMIT 1
}
RETURN person {
.name,
label: personLabel
} AS Person
GraphQL-Query
query { Person(name:"Jane") {name, nullable} }
GraphQL-Response
{
"Person" : {
"nullable" : null,
"name" : "Jane"
}
}
Cypher Params
{
"personName" : "Jane"
}
Cypher
CALL {
WITH $personName AS name
MATCH (p:Person { name: name }) RETURN p AS person LIMIT 1
}
CALL {
WITH person
WITH person AS this
RETURN null AS personNullable LIMIT 1
}
RETURN person {
.name,
nullable: personNullable
} AS Person