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.

features

Type: Neo4jFeaturesSettings

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

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.

ID

Type: Neo4jIDFiltersSettings

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.

MATCHES

Type: boolean

Enables MATCHES comparator.

Neo4jIDFiltersSettings

Name and Type Description

MATCHES

Type: boolean

Enables MATCHES 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.