@@ -130,6 +130,75 @@ const neoSchema = new Neo4jGraphQL({
130130})
131131----
132132
133+ ==== `requires` changes
134+
135+ In version 4.0.0, it is now possible to require non-scalar fields. This means it is also possible to require fields on related type.
136+ To make this possible, the `requires` argument now accept a graphql selection set instead of a list of strings.
137+
138+ Therefore, the following type definitions:
139+
140+ [source, graphql, indent=0]
141+ ----
142+ type User {
143+ firstName: String!
144+ lastName: String!
145+ fullName: String! @customResolver(requires: ["firstName", "lastName"])
146+ }
147+ ----
148+
149+ Would need to be modified to use a selection set as below:
150+
151+ [source, graphql, indent=0]
152+ ----
153+ type User {
154+ firstName: String!
155+ lastName: String!
156+ fullName: String! @customResolver(requires: "firstName lastName")
157+ }
158+ ----
159+
160+ Below is a more advanced example showing what the selection set is capable of:
161+
162+ [source, graphql, indent=0]
163+ ----
164+ interface Publication {
165+ publicationYear: Int!
166+ }
167+
168+ type Author {
169+ name: String!
170+ publications: [Publication!]! @relationship(type: "WROTE", direction: OUT)
171+ publicationsWithAuthor: [String!]!
172+ @customResolver(
173+ requires: "name publications { publicationYear ...on Book { title } ... on Journal { subject } }"
174+ )
175+ }
176+
177+ type Book implements Publication {
178+ title: String!
179+ publicationYear: Int!
180+ author: [Author!]! @relationship(type: "WROTE", direction: IN)
181+ }
182+
183+ type Journal implements Publication {
184+ subject: String!
185+ publicationYear: Int!
186+ author: [Author!]! @relationship(type: "WROTE", direction: IN)
187+ }
188+ ----
189+
190+ Additionally, the requires argument also validates the required selection set against your type definitions.
191+ Therefore, as there is no field called `someFieldThatDoesNotExist`, an error would be thrown on startup if you tried to use the following type definitions:
192+
193+ [source, graphql, indent=0]
194+ ----
195+ type User {
196+ firstName: String!
197+ lastName: String!
198+ fullName: String! @customResolver(requires: "firstName someFieldThatDoesNotExist")
199+ }
200+ ----
201+
133202[plural-migration]
134203=== `plural` argument removed from `@node` and replaced with `@plural`
135204
@@ -406,77 +475,6 @@ type query {
406475
407476Additionally, escaping strings is no longer needed.
408477
409- === `@customResolver` changes
410-
411- In version 4.0.0, it is now possible to require non-scalar fields. This means it is also possible to require fields on related type.
412- To make this possible, the `requires` argument now accept a graphql selection set instead of a list of strings.
413-
414- Therefore, the following type definitions:
415-
416- [source, graphql, indent=0]
417- ----
418- type User {
419- firstName: String!
420- lastName: String!
421- fullName: String! @customResolver(requires: ["firstName", "lastName"])
422- }
423- ----
424-
425- Would need to be modified to use a selection set as below:
426-
427- [source, graphql, indent=0]
428- ----
429- type User {
430- firstName: String!
431- lastName: String!
432- fullName: String! @customResolver(requires: "firstName lastName")
433- }
434- ----
435-
436- Below is a more advanced example showing what the selection set is capable of:
437-
438- [source, graphql, indent=0]
439- ----
440- interface Publication {
441- publicationYear: Int!
442- }
443-
444- type Author {
445- name: String!
446- publications: [Publication!]! @relationship(type: "WROTE", direction: OUT)
447- publicationsWithAuthor: [String!]!
448- @customResolver(
449- requires: "name publications { publicationYear ...on Book { title } ... on Journal { subject } }"
450- )
451- }
452-
453- type Book implements Publication {
454- title: String!
455- publicationYear: Int!
456- author: [Author!]! @relationship(type: "WROTE", direction: IN)
457- }
458-
459- type Journal implements Publication {
460- subject: String!
461- publicationYear: Int!
462- author: [Author!]! @relationship(type: "WROTE", direction: IN)
463- }
464- ----
465-
466- Additionally, the requires argument also validates the required selection set against your type definitions.
467- Therefore, as there is no field called `someFieldThatDoesNotExist`, an error would be thrown on startup if you tried to use the following type definitions:
468-
469- [source, graphql, indent=0]
470- ----
471- type User {
472- firstName: String!
473- lastName: String!
474- fullName: String! @customResolver(requires: "firstName someFieldThatDoesNotExist")
475- }
476- ----
477-
478-
479-
480478=== Mandatory `@relationshipProperties`
481479
482480Upcoming changes to interfaces require us to distinguish between interfaces that are used to specify relationship properties, and others. Therefore, the `@relationshipProperties` directive is now required on all relationship property interfaces.
0 commit comments