Directives

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

Directive Description

@alias

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

@authentication

Requires authentication checks when accessing the type.

@authorization

Specifies authorization rules for queries and mutations on the type.

@coalesce

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

@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.

@cypher

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

@declareRelationship

Configure relationships to be implemented on object types.

@default

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

@filterable

Defines the filters generated for a field.

@fulltext

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

@id

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

@jwtClaim

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

@limit

Used on nodes to inject values into Cypher LIMIT clauses.

@mutation

Limits the availability of Mutation operations in the library.

@node

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

@plural

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

@populatedBy

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

@private

Protects fields which should only be available through the OGM.

@query

Limits the availability of Query operations in the library.

@relationship

Configure relationships between object types.

@relationshipProperties

Required to help you distinguish between interfaces which are used for relationship properties, and otherwise. Can only be used on interfaces, as per its definition:

"""Required to differentiate between interfaces for relationship properties, and otherwise."""
directive @relationshipProperties on OBJECT

@relayId

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

@selectable

Sets the availability of fields on queries and aggregations.

@settable

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

@subscription

Limits subscription operations in the library.

@subscriptionsAuthorization

Specifies authorization rules for subscriptions on the type.

@timestamp

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

@unique

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