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
Copy file name to clipboardExpand all lines: modules/ROOT/pages/directives/indexes-and-constraints.adoc
-3Lines changed: 0 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -224,10 +224,7 @@ query {
224
224
225
225
== Asserting constraints
226
226
227
-
<<<<<<< HEAD
228
227
In order to ensure that the specified constraints exist in the database, you need to run the function `assertIndexesAndConstraints` (see more details in xref::reference/api-reference/neo4jgraphql.adoc#api-reference-assertconstraints[API reference]).
229
-
=======
230
-
>>>>>>> e36251b (fixing broken links)
231
228
A simple example to create the necessary constraints might look like the following, assuming a valid driver instance in the variable `driver`.
232
229
This creates two constraints, one for each field decorated with `@id` and `@unique`, and apply the indexes specified in `@fulltext`:
Copy file name to clipboardExpand all lines: modules/ROOT/pages/type-definitions/interfaces.adoc
+133-1Lines changed: 133 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,139 @@ This page describes how to use and define interfaces on relationship fields.
6
6
7
7
== Creating an interface field
8
8
9
-
Creating an interface field can be achieved through a mutation such as the following example, which adds an `Actor` and some productions they have acted in to the schema:
9
+
The following schema defines a `Actor` type, that has a relationship `ACTED_IN`, of type `[Production!]!`. `Production` is an interface type with `Movie` and `Series` implementations. Note in this example that relationship properties have also been used with the `@relationshipProperties` directive, so that interfaces representing relationship properties can be easily distinguished.
10
+
11
+
[source, graphql, indent=0]
12
+
----
13
+
interface Production {
14
+
title: String!
15
+
actors: [Actor!]!
16
+
}
17
+
18
+
type Movie implements Production {
19
+
title: String!
20
+
actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN, properties: "ActedIn")
21
+
runtime: Int!
22
+
}
23
+
24
+
type Series implements Production {
25
+
title: String!
26
+
actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN, properties: "ActedIn")
These type definitions will be used for the rest of the examples in this chapter.
41
+
42
+
=== Directive inheritance
43
+
44
+
Any directives present on an interface or its fields will be "inherited" by any object types implementing it. For example, the type definitions above could be refactored to have the `@relationship` directive on the `actors` field in the `Production` interface instead of on each implementing type as it is currently:
45
+
46
+
[source, graphql, indent=0]
47
+
----
48
+
interface Production {
49
+
title: String!
50
+
actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN, properties: "ActedIn")
This is to prevent overfetching, and you can find an explanation of this xref::troubleshooting.adoc#appendix-preventing-overfetching[here].
118
+
119
+
Alternatively, these implementation specific filters can be used to override filtering for a specific implementation. For example, if you wanted all productions with title starting with "The ", but movies with title starting with "A ", you could achieve this using the following:
120
+
121
+
[source, graphql, indent=0]
122
+
----
123
+
query GetProductionsStartingWith {
124
+
actors {
125
+
name
126
+
actedIn(where: { node: { title_STARTS_WITH: "The ", _on: { Movie: { title_STARTS_WITH: "A " } } } }) {
127
+
title
128
+
... on Movie {
129
+
runtime
130
+
}
131
+
... on Series {
132
+
episodes
133
+
}
134
+
}
135
+
}
136
+
}
137
+
----
138
+
139
+
== Creating using an interface field
140
+
141
+
The below mutation creates an actor and some productions they've acted in:
0 commit comments