Driver Configuration

1. Neo4j Driver

The Neo4j javascript driver must be present in either the context or construction of your Neo4jGraphQL API or at the construction of your OGM.

1.1. Neo4jGraphQL

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

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

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

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

Or you can specify the driver at runtime using the context;

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

1.2. OGM

const express = require("express");
const { OGM } = require("@neo4j/graphql");
const neo4j = require("neo4j-driver");

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

const ogm = new OGM({ typeDefs, driver });

2. checkNeo4jCompat

Use the checkNeo4jCompat method available on either Neo4jGraphQL or the OGM to ensure the specified DBMS has the required; versions, functions and procedures.

2.1. Neo4jGraphQL

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

2.2. OGM

const ogm = new OGM({ typeDefs, driver });
await ogm.checkNeo4jCompat();

3. Specifying Neo4j Database

The Neo4j database may be added to the GraphQL context object;

const server = new ApolloServer({
  schema,
  context: { driver, driverConfig: { database: "sanmateo" } }
});

4. Specifying Neo4j Bookmarks

A Neo4j driver bookmark may be added to the GraphQL context object;

const server = new ApolloServer({
  schema,
  context: { driver, driverConfig: { bookmarks: ["my-bookmark"] } }
});