diff --git a/modules/ROOT/pages/type-definitions/directives/autogeneration.adoc b/modules/ROOT/pages/type-definitions/directives/autogeneration.adoc index 0cd80b1c..0c34cb8a 100644 --- a/modules/ROOT/pages/type-definitions/directives/autogeneration.adoc +++ b/modules/ROOT/pages/type-definitions/directives/autogeneration.adoc @@ -7,28 +7,25 @@ This page describes directives used for autogeneration: [[type-definitions-autogeneration-id]] == `@id` -This directive marks a field as the unique identifier for an object type. -By default, that enables autogeneration of IDs for the field and implies that a unique node property constraint should exist for the property. +This directive marks a field as an identifier for an object type. +This enables autogeneration of IDs for the field. The format of each generated ID is a UUID generated by https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-randomuuid[randomUUID() function]. -If autogeneration for an ID field is enabled, the field will not be present in input types for mutations. +The field will not be present in input types for mutations. -See xref::/type-definitions/directives/indexes-and-constraints.adoc#type-definitions-constraints-unique[Unique node property constraints] for details on how to assert the existence of the necessary database constraints for relevant fields. +It is recommended to use xref::/type-definitions/directives/indexes-and-constraints.adoc#type-definitions-constraints-unique[`@unique`] in conjunction with this to add a unique node property constraint. === Definition [source, graphql, indent=0] ---- -"""Indicates that the field is an identifier for the object type. By default; autogenerated, and has a unique node property constraint in the database.""" -directive @id( - autogenerate: Boolean! = true - unique: Boolean! = true -) on FIELD_DEFINITION +"""Indicates that the field is an identifier for the object type.""" +directive @id on FIELD_DEFINITION ---- === Usage -The following two type definitions are equivalent in that they both specify an ID which benefits from autogeneration: +The following type definition specifies the `id` field as an autogenerated value: [source, graphql, indent=0] ---- @@ -38,34 +35,6 @@ type User { } ---- -[source, graphql, indent=0] ----- -type User { - id: ID! @id(autogenerate: true) - username: String! -} ----- - -The following type definition is currently a no-op, as the `@id` directive only provides autogeneration as it stands: - -[source, graphql, indent=0] ----- -type User { - id: ID! @id(autogenerate: false) - username: String! -} ----- - -You can disable the mapping of the `@id` directive to a unique node property constraint by setting the `unique` argument to `false`: - -[source, graphql, indent=0] ----- -type User { - id: ID! @id(unique: false) - username: String! -} ----- - [[type-definitions-autogeneration-timestamp]] == `@timestamp` diff --git a/modules/ROOT/pages/type-definitions/directives/index.adoc b/modules/ROOT/pages/type-definitions/directives/index.adoc index e0de5e14..9eb167ff 100644 --- a/modules/ROOT/pages/type-definitions/directives/index.adoc +++ b/modules/ROOT/pages/type-definitions/directives/index.adoc @@ -11,6 +11,12 @@ The Neo4j GraphQL Library provides the following directives to be used whilst de | xref::/type-definitions/directives/database-mapping.adoc#type-definitions-alias[`@alias`] | Maps a GraphQL schema field to a Neo4j property on a node or relationship. +| xref::/authentication-and-authorization/authentication.adoc[`@authentication`] +| Requires authentication checks when accessing the type. + +| xref::/authentication-and-authorization/authorization.adoc[`@authorization`] +| Specifies authorization rules for queries and mutations on the type. + | xref::/type-definitions/directives/default-values.adoc#type-definitions-default-values-coalesce[`@coalesce`] | Exposes a mechanism for querying against non-existent, `null` values on a node. @@ -68,6 +74,9 @@ Can only be used on interfaces, as per its definition: directive @relationshipProperties on INTERFACE ---- +| `@relayId` +| Specifies that the field should be used as the global node identifier for Relay. + | xref:/schema-configuration/field-configuration.adoc#_selectable[`@selectable`] | Sets the availability of fields on queries and aggregations. @@ -77,6 +86,9 @@ directive @relationshipProperties on INTERFACE | xref:/schema-configuration/type-configuration.adoc#_subscription[`@subscription`] | Limits subscription operations in the library. +| `@subscriptionsAuthorization` +| Specifies authorization rules for subscriptions on the type. + | xref::/type-definitions/directives/autogeneration.adoc#type-definitions-autogeneration-timestamp[`@timestamp`] | Flags fields to be used to store timestamps on create/update events.