Skip to content

Commit 099d76c

Browse files
authored
Merge pull request #290 from neo4j/aggregate-with-pagination
adds a note about using aggregate with pagination
2 parents c7205a3 + 00e4b8f commit 099d76c

File tree

1 file changed

+45
-4
lines changed

1 file changed

+45
-4
lines changed

modules/ROOT/pages/queries-aggregations/aggregations.adoc

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ Aggregations on a type are provided in the field `aggregate` inside Connection:
4949
query {
5050
usersConnection {
5151
aggregate {
52-
name {
53-
longest
52+
node {
53+
name {
54+
longest
55+
}
5456
}
5557
}
5658
}
@@ -94,8 +96,10 @@ a|
9496
query {
9597
postsConnection {
9698
aggregate {
97-
createdAt {
98-
min
99+
node {
100+
createdAt {
101+
min
102+
}
99103
}
100104
}
101105
}
@@ -220,3 +224,40 @@ query {
220224
}
221225
----
222226

227+
228+
== Aggregations and pagination
229+
230+
Since aggregations are done within the `Connection` type, the optional arguments `first` and `after` are available for pagination.
231+
However, pagination **does not** apply to aggregations.
232+
233+
For example:
234+
235+
[source, graphql, indent=0]
236+
----
237+
query {
238+
usersConnection(first: 10) {
239+
aggregate {
240+
count {
241+
nodes
242+
}
243+
}
244+
}
245+
}
246+
----
247+
248+
The result returns the count of all the nodes:
249+
250+
[source, json, indent=0]
251+
----
252+
{
253+
"usersConnection": {
254+
"aggregate": {
255+
"count": {
256+
"nodes": 38
257+
}
258+
}
259+
}
260+
}
261+
----
262+
263+

0 commit comments

Comments
 (0)