by neo4j-graphql

neo4j-graphql / neo4j-graphql-js

A GraphQL to Cypher query execution layer for Neo4j and JavaScript GraphQL implementations.

523 Stars 120 Forks Last release: Not found Other 1.0K Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

CI status codecov npm version Docs link


A GraphQL to Cypher query execution layer for Neo4j and JavaScript GraphQL implementations.

neo4j-graphql-js is in active development. There are rough edges and APIs may change. Please file issues for any bugs that you find or feature requests.

Installation and usage


npm install --save neo4j-graphql-js


Start with GraphQL type definitions:

const typeDefs = `
type Movie {
    title: String
    year: Int
    imdbRating: Float
    genres: [Genre] @relation(name: "IN_GENRE", direction: "OUT")
type Genre {
    name: String
    movies: [Movie] @relation(name: "IN_GENRE", direction: "IN")

Create an executable schema with auto-generated resolvers for Query and Mutation types, ordering, pagination, and support for computed fields defined using the

GraphQL schema directive:
import { makeAugmentedSchema } from 'neo4j-graphql-js';

const schema = makeAugmentedSchema({ typeDefs });

Create a neo4j-javascript-driver instance:

import { v1 as neo4j } from 'neo4j-driver';

const driver = neo4j.driver( 'bolt://localhost:7687', neo4j.auth.basic('neo4j', 'letmein') );

Use your favorite JavaScript GraphQL server implementation to serve your GraphQL schema, injecting the Neo4j driver instance into the context so your data can be resolved in Neo4j:

import { ApolloServer } from 'apollo-server';

const server = new ApolloServer({ schema, context: { driver } });

server.listen(3003, '').then(({ url }) => { console.log(GraphQL API ready at ${url}); });

If you don't want auto-generated resolvers, you can also call

in your GraphQL resolver. Your GraphQL query will be translated to Cypher and the query passed to Neo4j.
import { neo4jgraphql } from 'neo4j-graphql-js';

const resolvers = { Query: { Movie(object, params, ctx, resolveInfo) { return neo4jgraphql(object, params, ctx, resolveInfo); } } };

What is

A package to make it easier to use GraphQL and Neo4j together.

translates GraphQL queries to a single Cypher query, eliminating the need to write queries in GraphQL resolvers and for batching queries. It also exposes the Cypher query language through GraphQL via the
schema directive.


  • Translate GraphQL queries to Cypher to simplify the process of writing GraphQL resolvers
  • Allow for custom logic by overriding of any resolver function
  • Work with
    , and
  • Support GraphQL servers that need to resolve data from multiple data services/databases
  • Expose the power of Cypher through GraphQL via the


  • Send a single query to the database
  • No need to write queries for each resolver
  • Exposes the power of the Cypher query language through GraphQL


See our detailed contribution guidelines.


See /examples


Full docs can be found on

Debugging and Tuning

You can log out the generated cypher statements with an environment variable:

DEBUG=neo4j-graphql-js node yourcode.js

This helps to debug and optimize your database statements. E.g. visit your Neo4J browser console at http://localhost:7474/browser/ and paste the following:

:params :params { offset: 0, first: 12, filter: {}, cypherParams: { currentUserId: '42' } }

and now profile the generated query:

EXPLAIN MATCH (`post`:`Post`) WITH `post` ORDER BY post.createdAt DESC RETURN `post` { .id , .title } AS `post`

You can learn more by typing:

:help params

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.