The Neo4jGraphQL class

This is the documentation of the GraphQL Library version 7. For the long-term support (LTS) version 5, refer to GraphQL Library version 5 LTS.

You can assign different setting fields in the Neo4jGraphQL constructor:

export interface Neo4jGraphQLConstructor {
    typeDefs: TypeDefinitions; (1)
    resolvers?: IExecutableSchemaDefinition["resolvers"]; (2)
    features?: Neo4jFeaturesSettings; (3)
    driver?: Driver; (4)
    debug?: boolean;
    validate?: boolean;
}
1 See Types.
2 See Custom resolvers.
3 See Feature settings on this page.
4 See Driver configuration.

Feature settings

You can set different features in the features field of the Neo4j GraphQL constructor. The Neo4jFeaturesSettings type looks like this:

export type Neo4jFeaturesSettings = {
    filters?: Neo4jFiltersSettings;
    populatedBy?: Neo4jPopulatedBySettings;
    authorization?: Neo4jAuthorizationSettings;
    subscriptions?: Neo4jGraphQLSubscriptionsEngine | boolean;
    excludeDeprecatedFields?: {
        mutationOperations?: boolean;
        aggregationFilters?: boolean;
        aggregationFiltersOutsideConnection?: boolean;
        relationshipFilters?: boolean;
        attributeFilters?: boolean;
    };
    vector?: Neo4jVectorSettings;
    limitRequired?: boolean;
    complexityEstimators?: boolean;
    unsafeEscapeOptions?: {
        disableNodeLabelEscaping?: boolean;
        disableRelationshipTypeEscaping?: boolean;
    }
};

Filter settings

Use Neo4jFiltersSettings to enable numeric String comparisons and regular expression filters for Strings and IDs. They are disabled by default. See String comparison and RegEx matching.

populatedBy settings

Use the populatedBy field to register callback functions used by the @populatedBy directive. See @populatedBy.

Authorization settings

Set authorization keys in the authorization field. See Security > Configuration.

Subscription settings

Enable the subscriptions feature of the Neo4j GraphQL Library by setting it to true. It is also used to provide subscription settings. See Subscription engines.

Exclude deprecated fields

If you are not using them, use excludeDeprecatedFields to disable the generation of various deprecated fields. See Exclude @deprecated fields.

Vector settings

Set your GenAI provider credentials with the vector field. See @vector.

Limit required settings

Set limitRequired to true to require a limit argument for all read operations that return lists. This is useful to prevent unbounded queries that can lead to performance issues. See Avoid unbounded queries > Require limit argument.

Unsafe escape options

Changing these options is dangerous, and can lead to security risks.

These are options intended to disable automatic escaping of input values in the generated Cypher. By default, node labels and relationship types are escaped in the generated Cypher to ensure queries are safe.

This behavior can be disabled by using the flags inside unsafeEscapeOptions:

  • disableNodeLabelEscaping: Defaults to false. If set to true, node labels are not escaped.

  • disableRelationshipTypeEscaping: Defaults to false. If set to true, relationship types are not escaped.

Complexity estimators settings

Set complexityEstimators to true to enable the assignment of a complexity "score" to each field in the schema. This feature creates complexity estimators compatible with the graphql-query-complexity library, which can be used to generate the total complexity score of an incoming query via the getComplexity function. See Avoid unbounded queries > Complexity estimators.