Skip to content

Commit 0f073a5

Browse files
Merge pull request #189 from darrellwarde/remove-create-indexes
Remove references to `create` option on `assertIndexesAndConstraints`
2 parents 4b0c937 + b51cff0 commit 0f073a5

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ directive @unique(
1818
) on FIELD_DEFINITION
1919
----
2020

21-
Using this directive does not automatically ensure the existence of these constraints, and you will need to run a function on server startup.
22-
See the section xref::/directives/indexes-and-constraints.adoc#_asserting_constraints[Asserting constraints] for details.
21+
Using this directive does not automatically ensure the existence of these constraints, and you will need to create them manually.
2322

2423
=== Usage
2524

26-
`@unique` directives can only be used in GraphQL object types representing nodes, and they are only applicable for the "main" label for the node.
25+
`@unique` directives can only be used in GraphQL object types representing nodes, for any label specified on them.
2726

2827
In the following example, a unique constraint is asserted for the label `Colour` and the property `hexadecimal`:
2928

@@ -53,7 +52,7 @@ type Colour @node(labels: ["Color"]) {
5352
----
5453

5554
In the following example, all labels specified in the `labels` argument of the `@node` directive are also checked when asserting constraints.
56-
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`.
55+
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 when running `assertIndexesAndConstraints`.
5756

5857
[source, graphql, indent=0]
5958
----
@@ -64,7 +63,7 @@ type Colour @node(labels: ["Color", "Hue"]) {
6463

6564
== Fulltext indexes
6665

67-
You can use the `@fulltext` directive to add a https://neo4j.com/docs/cypher-manual/current/indexes-for-full-text-search/[Full text index] inside Neo4j.
66+
You can use the `@fulltext` directive to specify a https://neo4j.com/docs/cypher-manual/current/indexes-for-full-text-search/[full-text index] inside Neo4j.
6867
For example:
6968

7069
[source, graphql, indent=0]
@@ -82,13 +81,12 @@ directive @fulltext(indexes: [FullTextInput]!) on OBJECT
8281
----
8382

8483
Using this directive does not automatically ensure the existence of these indexes.
85-
You need to run a function on server startup.
86-
See the section xref::/directives/indexes-and-constraints.adoc#_asserting_constraints[Asserting constraints] for details.
84+
They must be created manually.
8785

8886
=== Specifying
8987

9088
The `@fulltext` directive can be used on nodes.
91-
In this example, a `Fulltext` index called "ProductName", for the name `field`, on the `Product` node, is added:
89+
In this example, a full-text index called "ProductName", for the name `field`, on the `Product` node, is specified:
9290

9391
[source, graphql, indent=0]
9492
----
@@ -98,7 +96,7 @@ type Product @fulltext(indexes: [{ indexName: "ProductName", fields: ["name"] }]
9896
}
9997
----
10098

101-
When you run xref::/directives/indexes-and-constraints.adoc#_asserting_constraints[Asserting constraints], they create the index like so:
99+
This index can be created in the database by running the following Cypher:
102100

103101
[source, cypher, indent=0]
104102
----
@@ -224,8 +222,8 @@ query {
224222
== Asserting constraints
225223

226224
In order to ensure that the specified constraints exist in the database, you need to run the function `assertIndexesAndConstraints`.
227-
A simple example to create the necessary constraints might look like the following, assuming a valid driver instance in the variable `driver`.
228-
This creates two constraints, one for each field decorated with `@id` and `@unique`, and apply the indexes specified in `@fulltext`:
225+
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`.
226+
This checks for the unique node property constraint for the field decorated `@unique`, and checks for the index specified in `@fulltext`:
229227

230228
[source, javascript, indent=0]
231229
----
@@ -245,10 +243,9 @@ const neoSchema = new Neo4jGraphQL({ typeDefs, driver });
245243
246244
const schema = await neoSchema.getSchema();
247245
248-
await neoSchema.assertIndexesAndConstraints({ options: { create: true }});
246+
await neoSchema.assertIndexesAndConstraints();
249247
----
250248

251-
252249
:description: Directives related to generative AI in the Neo4j GraphQL Library.
253250

254251
[role=label--beta]

0 commit comments

Comments
 (0)