Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ It generates the type `Actor`:
type Actor {
name: String!
age: Int
actedIn(where: MovieWhere, options: MovieOptions, directed: Boolean = true): [Movie!]!
actedIn(where: MovieWhere, sort: [MovieSort!]!, limit: Int, offset: Int, directed: Boolean = true): [Movie!]!
actedInAggregate(where: MovieWhere, directed: Boolean = true): ActorMovieActedInAggregationSelection
actedInConnection(where: ActorActedInConnectionWhere, first: Int, after: String, directed: Boolean = true, sort: [ActorActedInConnectionSort!]): ActorActedInConnection!
}
Expand Down Expand Up @@ -56,7 +56,7 @@ Now the type `Actor` looks like this:
----
type Actor {
name: String!
actedIn(where: MovieWhere, options: MovieOptions, directed: Boolean = true): [Movie!]!
actedIn(where: MovieWhere, sort: [MovieSort!]!, limit: Int, offset: Int, directed: Boolean = true): [Movie!]!
actedInAggregate(where: MovieWhere, directed: Boolean = true): ActorMovieActedInAggregationSelection
actedInConnection(where: ActorActedInConnectionWhere, first: Int, after: String, directed: Boolean = true, sort: [ActorActedInConnectionSort!]): ActorActedInConnection!
}
Expand Down Expand Up @@ -105,7 +105,7 @@ From the previous type definitions, the type `Actor` produced is:
----
type Actor {
name: String!
actedIn(where: MovieWhere, options: MovieOptions, directed: Boolean = true): [Movie!]!
actedIn(where: MovieWhere, sort: [MovieSort!]!, limit: Int, offset: Int, directed: Boolean = true): [Movie!]!
actedInAggregate(where: MovieWhere, directed: Boolean = true): ActorMovieActedInAggregationSelection
actedInConnection(where: ActorActedInConnectionWhere, first: Int, after: String, directed: Boolean = true, sort: [ActorActedInConnectionSort!]): ActorActedInConnection!
}
Expand Down Expand Up @@ -135,7 +135,7 @@ In this case, as the argument `aggregate` was passed as false, the type `Actor`
type Actor {
name: String!
age: Int
actedIn(where: MovieWhere, options: MovieOptions, directed: Boolean = true): [Movie!]!
actedIn(where: MovieWhere, sort: [MovieSort!]!, limit: Int, offset: Int, directed: Boolean = true): [Movie!]!
actedInConnection(where: ActorActedInConnectionWhere, first: Int, after: String, directed: Boolean = true, sort: [ActorActedInConnectionSort!]): ActorActedInConnection!
}
----
Expand Down Expand Up @@ -269,7 +269,7 @@ From the previous type definitions, the type `Actor` produced is:
----
type Actor {
name: String!
actedIn(where: MovieWhere, options: MovieOptions, directed: Boolean = true): [Movie!]!
actedIn(where: MovieWhere, sort: [MovieSort!]!, limit: Int, offset: Int, directed: Boolean = true): [Movie!]!
actedInAggregate(where: MovieWhere, directed: Boolean = true): ActorMovieActedInAggregationSelection
actedInConnection(where: ActorActedInConnectionWhere, first: Int, after: String, directed: Boolean = true, sort: [ActorActedInConnectionSort!]): ActorActedInConnection!
}
Expand Down Expand Up @@ -437,7 +437,7 @@ input MovieWhere {
OR: [MovieWhere!]
AND: [MovieWhere!]
NOT: MovieWhere
title: String
title_EQ: String
title_IN: [String!]
title_CONTAINS: String
title_STARTS_WITH: String
Expand Down Expand Up @@ -507,7 +507,7 @@ input MovieWhere {
OR: [MovieWhere!]
AND: [MovieWhere!]
NOT: MovieWhere
title: String
title_EQ: String
title_IN: [String!]
title_CONTAINS: String
title_STARTS_WITH: String
Expand Down
10 changes: 5 additions & 5 deletions modules/ROOT/pages/optimization.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ const neoSchema = new Neo4jGraphQL({
driver,
features: {
excludeDeprecatedFields: {
bookmark: true,
negationFilters: true,
arrayFilters: true,
stringAggregation: true,
aggregationFilters: true,
implicitEqualFilters: true;
deprecatedOptionsArgument: true;
directedArgument: true;
},
},
});
```

;

18 changes: 2 additions & 16 deletions modules/ROOT/pages/queries-aggregations/aggregations.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ For which the following query fields are generated:
[source, graphql, indent=0]
----
type Query {
posts(where: PostWhere, options: PostOptions): [Post!]!
posts(where: PostWhere, sort: [PostSort!]!, limit: Int, offset: Int,): [Post!]!
postsAggregate(where: PostWhere): PostAggregationSelection!
users(where: UserWhere, options: UserOptions): [User!]!
users(where: UserWhere, sort: [UserSort!]!, limit: Int, offset: Int,): [User!]!
usersAggregate(where: UserWhere): UserAggregationSelection!
}
----
Expand Down Expand Up @@ -180,17 +180,3 @@ query {
}
----

When performing an aggregation on related nodes, the query against the relationship
can be defined as "undirected" by using the argument `directed: false`:

[source, graphql, indent=0]
----
query {
users {
id
postsAggregate(directed: false) {
count
}
}
}
----
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ You would fetch the first "page" of 10 by executing:
[source, graphql, indent=0]
----
query {
users(options: {
limit: 10
}) {
users(limit: 10) {
name
}
}
Expand All @@ -33,10 +31,7 @@ And then on subsequent calls, introduce the `offset` argument and increment it b
[source, graphql, indent=0]
----
query {
users(options: {
offset: 10
limit: 10
}) {
users(offset: 10, limit: 10) {
name
}
}
Expand All @@ -47,10 +42,7 @@ query {
[source, graphql, indent=0]
----
query {
users(options: {
offset: 20
limit: 10
}) {
users(offset: 20, limit: 10) {
name
}
}
Expand All @@ -75,10 +67,7 @@ query {
name_EQ: "Billy"
}) {
name
posts(options: {
offset: 20
limit: 10
}) {
posts(offset: 20, limit: 10) {
content
}
}
Expand Down
46 changes: 2 additions & 44 deletions modules/ROOT/pages/queries-aggregations/queries.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ For which the following query fields are generated:
[source, graphql, indent=0]
----
type Query {
posts(where: PostWhere, options: PostOptions): [Post!]!
posts(where: PostWhere, sort: [PostSort!]!, limit: Int, offset: Int,): [Post!]!
postsAggregate(where: PostWhere): PostAggregationSelection!
users(where: UserWhere, options: UserOptions): [User!]!
users(where: UserWhere, sort: [UserSort!]!, limit: Int, offset: Int,): [User!]!
usersAggregate(where: UserWhere): UserAggregationSelection!
}
----
Expand Down Expand Up @@ -69,45 +69,3 @@ query {
}
}
----

== Undirected queries

All xref::/types/relationships.adoc[relationships] are created with a direction from one node to another.
By default, all queries follow the direction defined in the relationship.
However, in some cases it is necessary to query for all related nodes, regardless of the direction of the relationship.
This can be achieved with the argument `directed: false`.

For example, the following query should return all User friends, regardless of the direction of the relationship `"FRIENDS_WITH"`:

[source, graphql, indent=0]
----
query {
users {
name
friends: friends(directed: false) {
name
}
}
}
----

In addition, undirected relationships can also be used in the same fashion with connections.
For instance, this query is asking for a list of users and their friends' names with an undirected friendship connection:

[source, graphql, indent=0]
----
query Query {
users {
friendsConnection(directed: false) {
edges {
node {
name
}
}
}
}
}
----

Keep in mind that *undirected relationships are only supported in queries*.
The xref::/types/relationships.adoc#_querydirection[type definitions] for a relationship may define a different behavior, so the `directed` option may not be available in some cases.
19 changes: 5 additions & 14 deletions modules/ROOT/pages/queries-aggregations/sorting.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,8 @@ input MovieSort {
runtime: SortDirection
}

input MovieOptions {
"""Specify one or more MovieSort objects to sort Movies by. The sorts will be applied in the order in which they are arranged in the array."""
sort: [MovieSort!]
limit: Int
offset: Int
}

type Query {
movies(where: MovieWhere, options: MovieOptions): [Movie!]!
movies(where: MovieWhere, sort: [MovieSort!], limit: Int, offset: Int): [Movie!]!
}
----

Expand All @@ -52,13 +45,12 @@ The following query fetches all movies sorted by runtime in ascending order:
[source, graphql, indent=0]
----
query {
movies(options: {
sort: [
movies(sort: [
{
runtime: ASC
}
]
}) {
) {
title
runtime
}
Expand All @@ -73,13 +65,12 @@ query {
movies {
title
runtime
actors(options: {
sort: [
actors(sort: [
{
surname: ASC
}
]
}) {
) {
surname
}
}
Expand Down
Loading