Skip to content

Commit c308a0b

Browse files
authored
Merge pull request #266 from neo4j/remove-references-to-unique-directive-from-7.x
removed references to @unique from 7.x
2 parents bc2d55a + 9b87536 commit c308a0b

File tree

5 files changed

+1
-103
lines changed

5 files changed

+1
-103
lines changed

modules/ROOT/pages/directives/autogeneration.adoc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ This enables autogeneration of IDs for the field.
1515
The format of each generated ID is a UUID generated by the link:https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-randomuuid[`randomUUID()` function].
1616
The field will not be present in input types for mutations.
1717

18-
It is recommended to use xref::/directives/indexes-and-constraints.adoc#_unique[`@unique`] in conjunction with this to add a unique node property constraint.
19-
2018
=== Definition
2119

2220
[source, graphql, indent=0]

modules/ROOT/pages/directives/database-mapping.adoc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,6 @@ Defining `labels` means you take control of the database labels of the node.
111111
Indexes and constraints in Neo4j only support a single label, for which the first element of the `labels` argument is used.
112112
====
113113

114-
The following example results in a unique constraint to be asserted for the label `K9` and the property `name`:
115-
116-
[source, graphql, indent=0]
117-
----
118-
type Dog @node(labels: ["K9", "Dog"]) {
119-
name: String! @unique
120-
}
121-
----
122-
123-
See xref::/directives/indexes-and-constraints.adoc#_unique[`@unique`] to learn more about the `@unique` directive.
124-
125114

126115
==== Using `$jwt` and `$context`
127116

modules/ROOT/pages/directives/indexes-and-constraints.adoc

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -165,94 +165,6 @@ query {
165165
----
166166

167167

168-
== `@unique`
169-
170-
=== Definition
171-
172-
Unique node property constraints map to `@unique` directives used in your type definitions.
173-
They have the following definition:
174-
175-
[source, graphql, indent=0]
176-
----
177-
"""Informs @neo4j/graphql that there should be a uniqueness constraint in the database for the decorated field."""
178-
directive @unique(
179-
"""The name which should be used for this constraint. By default; type name, followed by an underscore, followed by the field name."""
180-
constraintName: String
181-
) on FIELD_DEFINITION
182-
----
183-
184-
Using this directive does not automatically ensure the existence of these constraints.
185-
Run a function on server startup.
186-
See section xref::/directives/indexes-and-constraints.adoc#_asserting_constraints[Asserting constraints] for details.
187-
188-
=== Usage
189-
190-
`@unique` directives can only be used in GraphQL object types representing nodes, and they are only applicable for the "main" label for the node.
191-
192-
In the following example, a unique constraint is asserted for the label `Colour` and the property `hexadecimal`:
193-
194-
[source, graphql, indent=0]
195-
----
196-
type Colour @node {
197-
hexadecimal: String! @unique
198-
}
199-
----
200-
201-
In the next example, a unique constraint with name `unique_colour` is asserted for the label `Colour` and the property `hexadecimal`:
202-
203-
[source, graphql, indent=0]
204-
----
205-
type Colour @node {
206-
hexadecimal: String! @unique(constraintName: "unique_colour")
207-
}
208-
----
209-
210-
The `@node` directive is used to change the database label mapping in this next example, so a unique constraint is asserted for the first label in the list, `Color`, and the property `hexadecimal`:
211-
212-
[source, graphql, indent=0]
213-
----
214-
type Colour @node(labels: ["Color"]) {
215-
hexadecimal: String! @unique
216-
}
217-
----
218-
219-
In the following example, all labels specified in the `labels` argument of the `@node` directive are also checked when asserting constraints.
220-
If there is a unique constraint specified for the `hexadecimal` property of nodes with the `Hue` label, but not the `Color` label, no error is thrown and no new constraints are created when running `assertIndexesAndConstraints`.
221-
222-
[source, graphql, indent=0]
223-
----
224-
type Colour @node(labels: ["Color", "Hue"]) {
225-
hexadecimal: String! @unique
226-
}
227-
----
228-
229-
== Asserting constraints
230-
231-
In order to ensure that the specified constraints exist in the database, you need to run the function `assertIndexesAndConstraints`.
232-
A simple example to check for the existence of the necessary constraints might look like the following, assuming a valid driver instance in the variable `driver`.
233-
This checks for the unique node property constraint for the field decorated `@unique`, and checks for the index specified in `@fulltext`:
234-
235-
[source, javascript, indent=0]
236-
----
237-
const typeDefs = `#graphql
238-
type Color @node {
239-
id: ID! @id
240-
hexadecimal: String! @unique
241-
}
242-
243-
type Product @fulltext(indexes: [{ indexName: "ProductName", fields: ["name"] }]) @node {
244-
name: String!
245-
color: Color! @relationship(type: "OF_COLOR", direction: OUT)
246-
}
247-
`;
248-
249-
const neoSchema = new Neo4jGraphQL({ typeDefs, driver });
250-
251-
const schema = await neoSchema.getSchema();
252-
253-
await neoSchema.assertIndexesAndConstraints();
254-
----
255-
256168
[#_vector_index_search]
257169
== `@vector`
258170

modules/ROOT/pages/integrations/apollo-federation.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ const typeDefs = `#graphql
207207
`;
208208
----
209209

210-
Although only the `@key` directive has been added to this example, consider using either the `@id` or the `@unique` directives on the `id` field.
210+
Although only the `@key` directive has been added to this example, consider using the `@id` directive on the `id` field.
211211
The Federation gateway expects each key to resolve to one result, so it is good practice to ensure that these values are unique in the database.
212212

213213
== Generate a subgraph schema

modules/ROOT/pages/integrations/relay-compatibility.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,4 @@ Also, the `Book` type is now refetchable via the `node` query field, and is read
7777
[WARNING]
7878
====
7979
The `@relayId` directive does not guarantee uniqueness.
80-
You should configure a unique node property constraint using xref:directives/indexes-and-constraints.adoc[the `@unique` directive].
8180
====

0 commit comments

Comments
 (0)