Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions modules/ROOT/pages/directives/autogeneration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The following type definition specifies the `id` field as an autogenerated value

[source, graphql, indent=0]
----
type User {
type User @node {
id: ID! @id
username: String!
}
Expand Down Expand Up @@ -70,7 +70,7 @@ The following type definition has two individual fields to store the timestamps

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

[source, graphql, indent=0]
----
type User {
type User @node {
lastModified: DateTime! @timestamp
}
----

[source, graphql, indent=0]
----
type User {
type User @node {
lastModified: DateTime! @timestamp(operations: [CREATE, UPDATE])
}
----
Expand Down
2 changes: 1 addition & 1 deletion modules/ROOT/pages/directives/custom-directives.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const neoSchema = new Neo4jGraphQL({
typeDefs: [
upperDirectiveTypeDefs,
`#graphql
type Movie {
type Movie @node {
name: String @uppercase
}
`,
Expand Down
38 changes: 19 additions & 19 deletions modules/ROOT/pages/directives/custom-logic.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ interface Auth {
a| You can use the JWT in the request to return the value of the currently logged in User:
[source, graphql, indent=0]
----
type User {
type User @node {
id: String
}

Expand Down Expand Up @@ -121,7 +121,7 @@ Both approaches are demonstrated here:

[source, graphql, indent=0]
----
type User {
type User @node {
id
}

Expand All @@ -139,7 +139,7 @@ type Query {

[source, graphql, indent=0]
----
type User {
type User @node {
id
}

Expand Down Expand Up @@ -189,13 +189,13 @@ In the following example, the field `similarMovies` is bound to the `Movie` type

[source, graphql, indent=0]
----
type Actor {
type Actor @node {
actorId: ID!
name: String
movies: [Movie!]! @relationship(type: "ACTED_IN", direction: OUT)
}

type Movie {
type Movie @node {
movieId: ID!
title: String
description: String
Expand All @@ -220,7 +220,7 @@ The following example demonstrates a query to return all of the actors in the da

[source, graphql, indent=0]
----
type Actor {
type Actor @node {
actorId: ID!
name: String
}
Expand All @@ -243,7 +243,7 @@ The following example demonstrates a mutation using a Cypher query to insert a s

[source, graphql, indent=0]
----
type Actor {
type Actor @node {
actorId: ID!
name: String
}
Expand Down Expand Up @@ -295,7 +295,7 @@ enum Status {
ACTIVE
INACTIVE
}
type Movie {
type Movie @node {
status: Status @coalesce(value: ACTIVE)
}
----
Expand Down Expand Up @@ -350,7 +350,7 @@ Take, for instance, this schema:
[source, javascript, indent=0]
----
const typeDefs = `
type User {
type User @node {
firstName: String!
lastName: String!
fullName: String! @customResolver(requires: "firstName lastName")
Expand Down Expand Up @@ -402,13 +402,13 @@ Using a selection set string makes it possible to select fields from related typ
[source, javascript, indent=0]
----
const typeDefs = `
type Address {
type Address @node {
houseNumber: Int!
street: String!
city: String!
}

type User {
type User @node {
id: ID!
firstName: String!
lastName: String!
Expand Down Expand Up @@ -442,7 +442,7 @@ interface Publication {
publicationYear: Int!
}

type Author {
type Author @node {
name: String!
publications: [Publication!]! @relationship(type: "WROTE", direction: OUT)
publicationsWithAuthor: [String!]!
Expand All @@ -451,13 +451,13 @@ type Author {
)
}

type Book implements Publication {
type Book implements Publication @node {
title: String!
publicationYear: Int!
author: [Author!]! @relationship(type: "WROTE", direction: IN)
}

type Journal implements Publication {
type Journal implements Publication @node {
subject: String!
publicationYear: Int!
author: [Author!]! @relationship(type: "WROTE", direction: IN)
Expand All @@ -473,7 +473,7 @@ interface Publication {
publicationYear: Int!
}

type Author {
type Author @node {
name: String!
publications: [Publication!]! @relationship(type: "WROTE", direction: OUT)
publicationsWithAuthor: [String!]!
Expand All @@ -482,13 +482,13 @@ type Author {
)
}

type Book implements Publication {
type Book implements Publication @node {
title: String!
publicationYear: Int!
author: [Author!]! @relationship(type: "WROTE", direction: IN)
}

type Journal implements Publication {
type Journal implements Publication @node {
subject: String!
publicationYear: Int!
author: [Author!]! @relationship(type: "WROTE", direction: IN)
Expand Down Expand Up @@ -530,7 +530,7 @@ Type definitions:

[source, graphql, indent=0]
----
type Product {
type Product @node {
name: String!
slug: String! @populatedBy(callback: "slug", operations: [CREATE, UPDATE])
}
Expand Down Expand Up @@ -566,7 +566,7 @@ For example, if you want a field `modifiedBy`:

[source, graphql, indent=0]
----
type Record {
type Record @node {
content: String!
modifiedBy: @populatedBy(callback: "modifiedBy", operations: [CREATE, UPDATE])
}
Expand Down
32 changes: 23 additions & 9 deletions modules/ROOT/pages/directives/database-mapping.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ To add a second node type, "Actor", and connect the two together, you should do

[source, graphql, indent=0]
----
type Movie {
type Movie @node {
title: String
actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN)
}

type Actor {
type Actor @node {
name: String
movies: [Movie!]! @relationship(type: "ACTED_IN", direction: OUT)
}
Expand Down Expand Up @@ -51,12 +51,12 @@ For example, for the "ACTED_IN" relationship, add a property "roles":

[source, graphql, indent=0]
----
type Movie {
type Movie @node {
title: String
actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN, properties: "ActedIn")
}

type Actor {
type Actor @node {
name: String
movies: [Movie!]! @relationship(type: "ACTED_IN", direction: OUT, properties: "ActedIn")
}
Expand All @@ -78,7 +78,7 @@ For example, to represent a node with the label "Movie" and a single property "t

[source, graphql, indent=0]
----
type Movie {
type Movie @node {
title: String
}
----
Expand Down Expand Up @@ -183,7 +183,21 @@ The following query yields a different Cypher query depending on the user JWT:
users {
name
}
}ref::/directives/database-mapping.adoc#_declarerelationship[
}
----

Assuming there is a user with the value `"username": "arthur"` in JWT, the Cypher query looks like:

[source, cypher, indent=0]
----
MATCH (this:arthur)
RETURN this { .name } as this
----

Similarly, context values can be passed directly:

[source, graphql, indent=0]
----
type User @node(label: ["$context.appId"]) {
name: String!
}
Expand Down Expand Up @@ -213,21 +227,21 @@ For example:

[source, graphql, indent=0]
----
type User {
type User @node {
id: ID! @id @alias(property: "dbId")
username: String!
}
----

[source, graphql, indent=0]
----
type User {
type User @node {
id: ID! @id
username: String! @alias(property: "dbUserName")
livesIn: [City!]! @relationship(direction: OUT, type: "LIVES_IN", properties: "UserLivesInProperties")
}

type City {
type City @node {
name: String
}

Expand Down
16 changes: 8 additions & 8 deletions modules/ROOT/pages/directives/indexes-and-constraints.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ In the following example, a unique constraint is asserted for the label `Colour`

[source, graphql, indent=0]
----
type Colour {
type Colour @node {
hexadecimal: String! @unique
}
----
Expand All @@ -38,7 +38,7 @@ In the next example, a unique constraint with name `unique_colour` is asserted f

[source, graphql, indent=0]
----
type Colour {
type Colour @node {
hexadecimal: String! @unique(constraintName: "unique_colour")
}
----
Expand Down Expand Up @@ -92,7 +92,7 @@ In this example, a `Fulltext` index called "ProductName", for the name `field`,

[source, graphql, indent=0]
----
type Product @fulltext(indexes: [{ indexName: "ProductName", fields: ["name"] }]) {
type Product @fulltext(indexes: [{ indexName: "ProductName", fields: ["name"] }]) @node {
name: String!
color: Color! @relationship(type: "OF_COLOR", direction: OUT)
}
Expand Down Expand Up @@ -191,7 +191,7 @@ Additionally, it is possible to define a custom query name as part of the `@full

[source, graphql, indent=0]
----
type Product @fulltext(indexes: [{ queryName: "CustomProductFulltextQuery", indexName: "ProductName", fields: ["name"] }]) {
type Product @fulltext(indexes: [{ queryName: "CustomProductFulltextQuery", indexName: "ProductName", fields: ["name"] }]) @node {
name: String!
color: Color! @relationship(type: "OF_COLOR", direction: OUT)
}
Expand Down Expand Up @@ -230,12 +230,12 @@ This creates two constraints, one for each field decorated with `@id` and `@uniq
[source, javascript, indent=0]
----
const typeDefs = `#graphql
type Color {
type Color @node {
id: ID! @id
hexadecimal: String! @unique
}

type Product @fulltext(indexes: [{ indexName: "ProductName", fields: ["name"] }]) {
type Product @fulltext(indexes: [{ indexName: "ProductName", fields: ["name"] }]) @node {
name: String!
color: Color! @relationship(type: "OF_COLOR", direction: OUT)
}
Expand Down Expand Up @@ -316,7 +316,7 @@ Perform a nearest neighbor search by passing a vector to find nodes with a vecto
.Type definition
[source, graphql]
----
type Product @vector(indexes: [{
type Product @node @vector(indexes: [{
indexName: "productDescriptionIndex",
embeddingProperty: "descriptionVector",
queryName: "searchByDescription"
Expand Down Expand Up @@ -399,7 +399,7 @@ See link:https://neo4j.com/docs/cypher-manual/current/genai-integrations/#ai-pro
.Type definition
[source, graphql]
----
type Product @vector(indexes: [{
type Product @node @vector(indexes: [{
indexName: "productDescriptionIndex",
embeddingProperty: "descriptionVector",
provider: OPEN_AI, # Assuming this is configured in the server
Expand Down
Loading