Neo4jGraphQL

constructor

Returns a Neo4jGraphQL instance.

Takes an input object as a parameter, the supported fields of which are described below.

Example

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

Input

Accepts all of the options from makeExecutableSchema, plus the additional arguments below:

Name and Type Description

driver

Type: Driver

An instance of a Neo4j driver.

config

Type: Neo4jGraphQLConfig

Additional Neo4j GraphQL configuration options.

features

Type: Neo4jFeaturesSettings

Could be used for configure/enable/disable specific features.

plugins

Type: Neo4jGraphQLPlugins

Plugins for the Neo4j GraphQL Library.

Neo4jGraphQLConfig

Name and Type Description

driverConfig

Type: DriverConfig

Additional driver configuration options.

enableRegex

Type: boolean

Whether to enable RegEx filters, see RegEx matching for more information.

queryOptions

Type: CypherQueryOptions

Cypher query options, see Query Tuning for more information.

skipValidateTypeDefs

Type: boolean

Can be used to disable strict type definition validation if you are encountering unexpected errors.

DriverConfig
Name and Type Description

database

Type: string

The name of the database within the DBMS to connect to.

bookmarks

Type: string or Array<string>

One or more bookmarks to use for the connection.

CypherQueryOptions

All options are enum types imported from @neo4j/graphql, for example:

const { CypherRuntime } = require("@neo4j/graphql");
Name and Type Description

runtime

Type: CypherRuntime

Possible options:

- CypherRuntime.INTERPRETED
- CypherRuntime.SLOTTED
- CypherRuntime.PIPELINED

planner

Type: CypherPlanner

Possible options:

- CypherPlanner.COST
- CypherPlanner.IDP
- CypherPlanner.DP

connectComponentsPlanner

Type: CypherConnectComponentsPlanner

Possible options:

- CypherConnectComponentsPlanner.GREEDY
- CypherConnectComponentsPlanner.IDP

updateStrategy

Type: CypherUpdateStrategy

Possible options:

- CypherUpdateStrategy.DEFAULT
- CypherUpdateStrategy.EAGER

expressionEngine

Type: CypherExpressionEngine

Possible options:

- CypherExpressionEngine.DEFAULT
- CypherExpressionEngine.INTERPRETED
- CypherExpressionEngine.COMPILED

operatorEngine

Type: CypherOperatorEngine

Possible options:

- CypherOperatorEngine.DEFAULT
- CypherOperatorEngine.INTERPRETED
- CypherOperatorEngine.COMPILED

interpretedPipesFallback

Type: CypherInterpretedPipesFallback

Possible options:

- CypherInterpretedPipesFallback.DEFAULT
- CypherInterpretedPipesFallback.DISABLED
- CypherInterpretedPipesFallback.WHITELISTED_PLANS_ONLY
- CypherInterpretedPipesFallback.ALL

replan

Type: CypherReplanning

Possible options:

- CypherReplanning.DEFAULT
- CypherReplanning.FORCE
- CypherReplanning.SKIP

Neo4jFeaturesSettings

Name and Type Description

filters

Type: Neo4jFiltersSettings

Additional configuration for filters.

Neo4jFiltersSettings

Name and Type Description

String

Type: Neo4jStringFiltersSettings

Additional configuration for String filters.

Neo4jStringFiltersSettings

Name and Type Description

GT

Type: boolean

Enables GT comparator.

GTE

Type: boolean

Enables GTE comparator.

LT

Type: boolean

Enables LT comparator.

LTE

Type: boolean

Enables LTE comparator.

Neo4jGraphQLPlugins

Name and Type Description

auth

Type: Neo4jGraphQLAuthPlugin

Plugin slot for auth capabilities.

getSchema

An asynchronous method that generates the GraphQL schema to be used in a server. The result is memoized, so if this is called twice, the schema is only generated once.

checkNeo4jCompat

Asynchronous method to check the compatibility of the specified DBMS, that either resolves to void in a successful scenario, or throws an error if the database is not compatible with the Neo4j GraphQL Library.

Takes an input object as a parameter, the supported fields of which are described below.

Example

Given any valid type definitions saved to the variable typeDefs and a valid driver instance saved to the variable driver, the following will confirm database compatibility:

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

Input

Accepts the arguments below:

Name and Type Description

driver

Type: Driver

An instance of a Neo4j driver.

driverConfig

Type: DriverConfig

Additional driver configuration options.

DriverConfig

Name and Type Description

database

Type: string

The name of the database within the DBMS to connect to.

bookmarks

Type: string or Array<string>

One or more bookmarks to use for the connection.

assertIndexesAndConstraints

Asynchronous method to assert the existence of database constraints, that either resolves to void in a successful scenario, or throws an error if the necessary constraints do not exist following its execution.

Takes an input object as a parameter, the supported fields of which are described below.

Example

Given the following type definitions saved to the variable typeDefs and a valid driver instance saved to the variable driver:

type Book {
    isbn: String! @unique
}

And the construction of a Neo4jGraphQL, using:

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

The following will check whether a unique node property constraint exists for label "Book" and property "isbn", and throw an error if it does not:

await neoSchema.assertIndexesAndConstraints();

The next example will create the constraint if it does not exist:

await neoSchema.assertIndexesAndConstraints({ options: { create: true } });

Input

Accepts the arguments below:

Name and Type Description

driver

Type: Driver

An instance of a Neo4j driver.

driverConfig

Type: DriverConfig

Additional driver configuration options.

options

Type: AssertConstraintsOptions

Options for the execution of assertIndexesAndConstraints.

DriverConfig

Name and Type Description

database

Type: string

The name of the database within the DBMS to connect to.

bookmarks

Type: string or Array<string>

One or more bookmarks to use for the connection.

AssertConstraintsOptions

Name and Type Description

create

Type: boolean

Whether or not to create constraints if they do not yet exist. Disabled by default.