Directives

The Neo4j GraphQL Library provides the following directives to be used whilst defining types:

Database mapping

Directive Description

@relationship

Configures relationships between object types.

@relationshipProperties

Required to differentiate interfaces that are used for relationship properties, and otherwise.

@node

Specifies the configuration of a GraphQL object type which represents a Neo4j node.

@alias

Maps a GraphQL schema field to a Neo4j property on a node or relationship.

@declareRelationship

Configure relationships to be implemented on object types.

Security

Directive Description

@authentication

Requires authentication checks when accessing the type.

@authorization

Specifies authorization rules for queries and mutations on the type.

@jwt

Configures the JWT authentication and authorization filters to include additional JWT claims.

@jwtClaim

Used in combination with @jwt. Configures the JWT authentication and authorization filters to include an additional JWT claim which is either nested or using special characters not supported by GraphQL.

@subscriptionsAuthorization

Specifies authorization rules for subscriptions on the type.

Autogeneration

Directive Description

@id

Marks a field as the unique ID for an object type, and allows for autogeneration of IDs.

@timestamp

Flags fields to be used to store timestamps on create and update events.

Schema configuration

Directive Description

@query

Limits the availability of query operations in the library.

@mutation

Limits the availability of Mutation operations in the library.

@subscription

Limits subscription operations in the library.

@default

Allows the setting of a default value for a field during object creation.

@plural

Redefines how to compose the plural of the type for the generated operations. Particularly useful for types that are not correctly pluralized or are non-English words.

@selectable

Sets the availability of fields on queries and aggregations.

@settable

Sets the availability of fields on the create and update inputs.

@filterable

Defines the filters generated for a field.

Indexes and constraints

Directive Description

@fulltext

Indicates that there should be a fulltext index inserted into the database for the specified Node and its properties.

@unique

Indicates that there should be a uniqueness constraint in the database for the fields that it is applied to.

@vector

Perform a vector index search on your database either based by passing in a vector index or a search phrase. Beta

Custom logic

Directive Description

@cypher

Overrides field resolution (including query and mutation fields), instead resolving with the specified Cypher.

@coalesce

Exposes a mechanism for querying against non-existent, null values on a node.

@limit

Used on nodes to inject values into Cypher LIMIT clauses.

@customResolver

Specifies that a field is resolved by a custom resolver, and allows the specification of any required fields that is passed as arguments to the custom resolver.

@populatedBy

Specifies a callback function (executed during GraphQL query parsing) to populate fields which have not been provided within the input.

OGM

Directive Description

@private

Protects fields which should only be available through the OGM.

Relay

Directive Description

@relayId

Specifies that the field should be used as the global node identifier for Relay.