Getting Started

This section will help users get started with Neo4j GraphQL. Before starting we recommend readers have an understanding of the following prerequisites;

1. Installation

$ npm install @neo4j/graphql

graphql and neo4j-driver are peerDependencies, so unless the project already has them installed they need to be installed as well.

2. Requiring

The Library is transpiled, from our TypeScript source, into Common JS - This means you can use the require or the import syntax to access the library’s exported members, depending on your environment and tooling setup;

const { Neo4jGraphQL } = require("@neo4j/graphql");


import { Neo4jGraphQL } from "@neo4j/graphql";

3. GraphQL API Quick Start

This section demonstrates using Apollo Server alongside Neo4jGraphQL to spin up a GraphQL API.

$ npm install @neo4j/graphql graphql neo4j-driver apollo-server
const { Neo4jGraphQL } = require("@neo4j/graphql");
const neo4j = require("neo4j-driver");
const { ApolloServer } = require("apollo-server");

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

    type Genre {
        name: String
        movies: [Movie] @relationship(type: "IN_GENRE", direction: IN)

const driver = neo4j.driver(
    neo4j.auth.basic("neo4j", "letmein")

const neoSchema = new Neo4jGraphQL({ typeDefs, driver });

const server = new ApolloServer({
    schema: neoSchema.schema,
    context: ({ req }) => ({ req }),

server.listen(4000).then(() => console.log("Online"));