Skip to content

Commit a409205

Browse files
Remove references to deprecated directives (neo4j#11)
Co-authored-by: Lidia Zuin <[email protected]>
1 parent fab2617 commit a409205

File tree

3 files changed

+141
-5
lines changed

3 files changed

+141
-5
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,7 @@ query {
224224

225225
== Asserting constraints
226226

227-
<<<<<<< HEAD
228227
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)
231228
A simple example to create the necessary constraints might look like the following, assuming a valid driver instance in the variable `driver`.
232229
This creates two constraints, one for each field decorated with `@id` and `@unique`, and apply the indexes specified in `@fulltext`:
233230

modules/ROOT/pages/directives/reference.adoc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
The `@alias` directive will map a GraphQL schema field to a Neo4j property on a node or relationship.
88

9-
Reference: xref::reference/directives/database-mapping.adoc#type-definitions-alias[`@alias`]
9+
Reference: xref::/directives/database-mapping.adoc#type-definitions-alias[`@alias`]
1010

1111
== `@coalesce`
1212

@@ -116,6 +116,7 @@ The `@queryOptions` is to be used on nodes, where applied will inject values int
116116
117117
Reference: xref::/directives/default-values.adoc#type-definitions-default-values-queryoptions[`@queryOptions`]
118118
119+
<<<<<<< HEAD
119120
== `@readonly` label:deprecated[]
120121
121122
This directive is deprecated. See the xref:/schema-configuration/field-configuration.adoc#_settable[`@settable`] directive.
@@ -124,6 +125,8 @@ The `@readonly` directive marks fields as read-only.
124125
Reference: xref::/schema-configuration/field-configuration.adoc#_readonly_deprecated[`@readonly`]
125126
>>>>>>> e36251b (fixing broken links)
126127
128+
=======
129+
>>>>>>> dbb023b (Remove references to deprecated directives (#11))
127130
== `@relationship`
128131

129132
The `@relationship` directive is used to configure relationships between object types.
@@ -170,6 +173,7 @@ Reference: xref::/directives/autogeneration.adoc#type-definitions-autogeneration
170173

171174
The `@unique` directive indicates that there should be a uniqueness constraint in the database for the fields that it is applied to.
172175

176+
<<<<<<< HEAD
173177
<<<<<<< HEAD
174178
Reference: xref::reference/type-definitions/indexes-and-constraints.adoc#type-definitions-constraints-unique[Unique node property constraints]
175179
=======
@@ -184,3 +188,6 @@ The `@writeonly` directive marks fields as write-only.
184188
185189
Reference: xref::/schema-configuration/field-configuration.adoc#_writeonly_deprecated[`@writeonly`]
186190
>>>>>>> e36251b (fixing broken links)
191+
=======
192+
Reference: xref::reference/type-definitions/indexes-and-constraints.adoc#type-definitions-constraints-unique[Unique node property constraints]
193+
>>>>>>> dbb023b (Remove references to deprecated directives (#11))

modules/ROOT/pages/type-definitions/interfaces.adoc

Lines changed: 133 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,139 @@ This page describes how to use and define interfaces on relationship fields.
66

77
== Creating an interface field
88

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")
27+
episodes: Int!
28+
}
29+
30+
interface ActedIn @relationshipProperties {
31+
role: String!
32+
}
33+
34+
type Actor {
35+
name: String!
36+
actedIn: [Production!]! @relationship(type: "ACTED_IN", direction: OUT, properties: "ActedIn")
37+
}
38+
----
39+
40+
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")
51+
}
52+
53+
type Movie implements Production {
54+
title: String!
55+
actors: [Actor!]!
56+
runtime: Int!
57+
}
58+
59+
type Series implements Production {
60+
title: String!
61+
actors: [Actor!]!
62+
episodes: Int!
63+
}
64+
65+
interface ActedIn @relationshipProperties {
66+
role: String!
67+
}
68+
69+
type Actor {
70+
name: String!
71+
actedIn: [Production!]! @relationship(type: "ACTED_IN", direction: OUT, properties: "ActedIn")
72+
}
73+
----
74+
75+
[[type-definitions-interfaced-types-querying]]
76+
== Querying an interface
77+
78+
Which implementations are returned by a query are dictated by the `where` filter applied.
79+
80+
For example, the following will return all productions with title starting "The " for every actor:
81+
82+
[source, graphql, indent=0]
83+
----
84+
query GetProductionsStartingWithThe {
85+
actors {
86+
name
87+
actedIn(where: { node: { title_STARTS_WITH: "The " } }) {
88+
title
89+
... on Movie {
90+
runtime
91+
}
92+
... on Series {
93+
episodes
94+
}
95+
}
96+
}
97+
}
98+
----
99+
100+
Whilst the query below will only return the movies with title starting with "The " for each actor.
101+
102+
[source, graphql, indent=0]
103+
----
104+
query GetMoviesStartingWithThe {
105+
actors {
106+
name
107+
actedIn(where: { node: { _on: { Movie: { title_STARTS_WITH: "The " } } } }) {
108+
title
109+
... on Movie {
110+
runtime
111+
}
112+
}
113+
}
114+
}
115+
----
116+
117+
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:
10142

11143
[source, graphql, indent=0]
12144
----

0 commit comments

Comments
 (0)