Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
We wanted to combine the power of Neo4j and GraphQL by making it super easy to take an IDL schema OR an existing graph and serve a native GraphQL backend from it.
With the information from the schema, we are able to generate a single query against the backing graph database. During development, both Neo4j’s property graph model and the Cypher query language turned out to be great fits for the GraphQL features supported so far.
You can grab the latest release of our extension from here and drop it into any Neo4j 3.1.x server (in the plugins
directory).
After a restart, you can either query your graph data using GraphQL directly or by posting an IDL file with your preferred schema.
We added some neat features that we hope are useful and make your life easier.
We are especially proud of the @cypher
directive, the auto-generated mutations (create, update, delete), and the graphql.execute
, graphql.idl
and graphql.schema
procedures.
Here is an example of how the schema definition above could or would be extended:
type Movie {
title: ID!
released: Int
tagline: String
actors: [Person] @relation(name:"ACTED_IN", direction:IN)
director: Person @relation(name:"DIRECTED", direction:IN)
recommendation(first:Int = 3): [Movie]
@cypher(statement:"MATCH (this)<-[r1:REVIEWED]-(:User)-[r2:REVIEWED]->(reco:Movie)
WHERE 3 <= r1.stars <= r2.stars
RETURN reco, sum(r2.stars) as rating ORDER BY rating DESC")
}
interface Person {
name: ID!
born: Int
}
type Actor extends Person {
name: ID!
born: Int
movies: [Movie] @relation(name:"ACTED_IN")
}
type Director extends Person {
name: ID!
born: Int
movies: [Movie] @relation(name:"DIRECTED")
}
type Mutations {
directed(movie:ID! director:ID!) : String
@cypher(statement:"MATCH (m:Movie {title: $movie}), (d:Person {name: $director})
MERGE (d)-[:DIRECTED]->(m)")
}
schema {
mutations: Mutations
}
Have a look at the following "feature" table to see what else comes "in the box":