Skip to content

Commit e863968

Browse files
Merge pull request #188 from MacondoExpress/use-node-directive-v2
Update examples with `@node` directive
2 parents b17fad4 + 9e5fb48 commit e863968

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+333
-490
lines changed

modules/ROOT/pages/directives/autogeneration.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The following type definition specifies the `id` field as an autogenerated value
3131

3232
[source, graphql, indent=0]
3333
----
34-
type User {
34+
type User @node {
3535
id: ID! @id
3636
username: String!
3737
}
@@ -70,7 +70,7 @@ The following type definition has two individual fields to store the timestamps
7070

7171
[source, graphql, indent=0]
7272
----
73-
type User {
73+
type User @node {
7474
createdAt: DateTime! @timestamp(operations: [CREATE])
7575
updatedAt: DateTime! @timestamp(operations: [UPDATE])
7676
}
@@ -80,14 +80,14 @@ The following two equivalent type definitions have a single field storing the ev
8080

8181
[source, graphql, indent=0]
8282
----
83-
type User {
83+
type User @node {
8484
lastModified: DateTime! @timestamp
8585
}
8686
----
8787

8888
[source, graphql, indent=0]
8989
----
90-
type User {
90+
type User @node {
9191
lastModified: DateTime! @timestamp(operations: [CREATE, UPDATE])
9292
}
9393
----

modules/ROOT/pages/directives/custom-directives.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const neoSchema = new Neo4jGraphQL({
5757
typeDefs: [
5858
upperDirectiveTypeDefs,
5959
`#graphql
60-
type Movie {
60+
type Movie @node {
6161
name: String @uppercase
6262
}
6363
`,

modules/ROOT/pages/directives/custom-logic.adoc

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ interface Auth {
4747
a| You can use the JWT in the request to return the value of the currently logged in User:
4848
[source, graphql, indent=0]
4949
----
50-
type User {
50+
type User @node {
5151
id: String
5252
}
5353
@@ -117,7 +117,7 @@ Both approaches are demonstrated here:
117117

118118
[source, graphql, indent=0]
119119
----
120-
type User {
120+
type User @node {
121121
id
122122
}
123123
@@ -135,7 +135,7 @@ type Query {
135135

136136
[source, graphql, indent=0]
137137
----
138-
type User {
138+
type User @node {
139139
id
140140
}
141141
@@ -185,13 +185,13 @@ In the following example, the field `similarMovies` is bound to the `Movie` type
185185

186186
[source, graphql, indent=0]
187187
----
188-
type Actor {
188+
type Actor @node {
189189
actorId: ID!
190190
name: String
191191
movies: [Movie!]! @relationship(type: "ACTED_IN", direction: OUT)
192192
}
193193
194-
type Movie {
194+
type Movie @node {
195195
movieId: ID!
196196
title: String
197197
description: String
@@ -216,7 +216,7 @@ The following example demonstrates a query to return all of the actors in the da
216216

217217
[source, graphql, indent=0]
218218
----
219-
type Actor {
219+
type Actor @node {
220220
actorId: ID!
221221
name: String
222222
}
@@ -239,7 +239,7 @@ The following example demonstrates a mutation using a Cypher query to insert a s
239239

240240
[source, graphql, indent=0]
241241
----
242-
type Actor {
242+
type Actor @node {
243243
actorId: ID!
244244
name: String
245245
}
@@ -291,7 +291,7 @@ enum Status {
291291
ACTIVE
292292
INACTIVE
293293
}
294-
type Movie {
294+
type Movie @node {
295295
status: Status @coalesce(value: ACTIVE)
296296
}
297297
----
@@ -345,7 +345,7 @@ Take, for instance, this schema:
345345
[source, javascript, indent=0]
346346
----
347347
const typeDefs = `
348-
type User {
348+
type User @node {
349349
firstName: String!
350350
lastName: String!
351351
fullName: String! @customResolver(requires: "firstName lastName")
@@ -397,13 +397,13 @@ Using a selection set string makes it possible to select fields from related typ
397397
[source, javascript, indent=0]
398398
----
399399
const typeDefs = `
400-
type Address {
400+
type Address @node {
401401
houseNumber: Int!
402402
street: String!
403403
city: String!
404404
}
405405
406-
type User {
406+
type User @node {
407407
id: ID!
408408
firstName: String!
409409
lastName: String!
@@ -437,7 +437,7 @@ interface Publication {
437437
publicationYear: Int!
438438
}
439439
440-
type Author {
440+
type Author @node {
441441
name: String!
442442
publications: [Publication!]! @relationship(type: "WROTE", direction: OUT)
443443
publicationsWithAuthor: [String!]!
@@ -446,13 +446,13 @@ type Author {
446446
)
447447
}
448448
449-
type Book implements Publication {
449+
type Book implements Publication @node {
450450
title: String!
451451
publicationYear: Int!
452452
author: [Author!]! @relationship(type: "WROTE", direction: IN)
453453
}
454454
455-
type Journal implements Publication {
455+
type Journal implements Publication @node {
456456
subject: String!
457457
publicationYear: Int!
458458
author: [Author!]! @relationship(type: "WROTE", direction: IN)
@@ -468,7 +468,7 @@ interface Publication {
468468
publicationYear: Int!
469469
}
470470
471-
type Author {
471+
type Author @node {
472472
name: String!
473473
publications: [Publication!]! @relationship(type: "WROTE", direction: OUT)
474474
publicationsWithAuthor: [String!]!
@@ -477,13 +477,13 @@ type Author {
477477
)
478478
}
479479
480-
type Book implements Publication {
480+
type Book implements Publication @node {
481481
title: String!
482482
publicationYear: Int!
483483
author: [Author!]! @relationship(type: "WROTE", direction: IN)
484484
}
485485
486-
type Journal implements Publication {
486+
type Journal implements Publication @node {
487487
subject: String!
488488
publicationYear: Int!
489489
author: [Author!]! @relationship(type: "WROTE", direction: IN)
@@ -525,7 +525,7 @@ Type definitions:
525525

526526
[source, graphql, indent=0]
527527
----
528-
type Product {
528+
type Product @node {
529529
name: String!
530530
slug: String! @populatedBy(callback: "slug", operations: [CREATE, UPDATE])
531531
}
@@ -561,7 +561,7 @@ For example, if you want a field `modifiedBy`:
561561

562562
[source, graphql, indent=0]
563563
----
564-
type Record {
564+
type Record @node {
565565
content: String!
566566
modifiedBy: @populatedBy(callback: "modifiedBy", operations: [CREATE, UPDATE])
567567
}

0 commit comments

Comments
 (0)