You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds a few missing directives to the index, and fixes some discrepancies (#27)
* Adds a few missing directives to the index, and fixes some discrepancies
* Apply suggestions from code review
Co-authored-by: Lidia Zuin <[email protected]>
---------
Co-authored-by: Lidia Zuin <[email protected]>
Copy file name to clipboardExpand all lines: modules/ROOT/pages/type-definitions/directives/autogeneration.adoc
+7-38Lines changed: 7 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,28 +7,25 @@ This page describes directives used for autogeneration:
7
7
[[type-definitions-autogeneration-id]]
8
8
== `@id`
9
9
10
-
This directive marks a field as the unique identifier for an object type.
11
-
By default, that enables autogeneration of IDs for the field and implies that a unique node property constraint should exist for the property.
10
+
This directive marks a field as an identifier for an object type.
11
+
This enables autogeneration of IDs for the field.
12
12
13
13
The format of each generated ID is a UUID generated by https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-randomuuid[randomUUID() function].
14
-
If autogeneration for an ID field is enabled, the field will not be present in input types for mutations.
14
+
The field will not be present in input types for mutations.
15
15
16
-
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.
16
+
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.
17
17
18
18
=== Definition
19
19
20
20
[source, graphql, indent=0]
21
21
----
22
-
"""Indicates that the field is an identifier for the object type. By default; autogenerated, and has a unique node property constraint in the database."""
23
-
directive @id(
24
-
autogenerate: Boolean! = true
25
-
unique: Boolean! = true
26
-
) on FIELD_DEFINITION
22
+
"""Indicates that the field is an identifier for the object type."""
23
+
directive @id on FIELD_DEFINITION
27
24
----
28
25
29
26
=== Usage
30
27
31
-
The following two type definitions are equivalent in that they both specify an ID which benefits from autogeneration:
28
+
The following type definition specifies the `id` field as an autogenerated value:
32
29
33
30
[source, graphql, indent=0]
34
31
----
@@ -38,34 +35,6 @@ type User {
38
35
}
39
36
----
40
37
41
-
[source, graphql, indent=0]
42
-
----
43
-
type User {
44
-
id: ID! @id(autogenerate: true)
45
-
username: String!
46
-
}
47
-
----
48
-
49
-
The following type definition is currently a no-op, as the `@id` directive only provides autogeneration as it stands:
50
-
51
-
[source, graphql, indent=0]
52
-
----
53
-
type User {
54
-
id: ID! @id(autogenerate: false)
55
-
username: String!
56
-
}
57
-
----
58
-
59
-
You can disable the mapping of the `@id` directive to a unique node property constraint by setting the `unique` argument to `false`:
0 commit comments