Skip to content

Commit 6ba4087

Browse files
authored
Reviewing Queries and aggregations section (#12)
* Reviewing Queries and aggregations section * update after review * update after review * Restructuring the index page with example type definitions and review of the queries and aggregations pages * fixing title levels * Review of filtering.adoc * removing unnecessary description * Sorting page review * changes after review
1 parent e35ede3 commit 6ba4087

File tree

7 files changed

+279
-537
lines changed

7 files changed

+279
-537
lines changed

modules/ROOT/pages/deprecations.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ The following products and applications are deprecated:
1010
== GRANDstack starter app
1111

1212
The main purpose of the GRANDstack starter app was to demonstrate how the Neo4j Labs GraphQL library could be used in the context of a full-stack application using React and Apollo client.
13-
It allowed developers to build applications more quickly and with a bigger focus on functionality, while also helping users who already had an existing front end and needed a new back end.
13+
It allowed developers to build applications more quickly and with a bigger focus on functionality, while also helping users who already had an existing frontend and needed a new back end.
1414

1515
Over time, the GRANDstack starter app grew to support other frameworks such as Flutter and Angular, thus the need to revisit its scope.
16-
The intention is to replace this project with a new starter application product, which will focus on the back end and the configuration of the GraphQL library, as well as help developers with their front end.
16+
The intention is to replace this project with a new starter application product, which will focus on the back end and the configuration of the GraphQL library, as well as help developers with their frontend.
1717

1818
In the meantime, the `create-grandstack-app` npm package has been marked as deprecated.
1919
It can still be used to skeleton a GRANDstack app, but the user will be warned that the package is deprecated.

modules/ROOT/pages/index.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
The Neo4j GraphQL Library is a highly flexible, low-code, open source JavaScript library that enables rapid API development for cross-platform and mobile applications by tapping into the power of connected data.
66

7-
With Neo4j as the graph database, the GraphQL Library makes it simple for applications to have data treated as a graph natively from the front end all the way to storage.
8-
This avoids duplicate schema work and ensures flawless integration between front-end and back-end developers.
7+
With Neo4j as the graph database, the GraphQL Library makes it simple for applications to have data treated as a graph natively from the frontend all the way to storage.
8+
This avoids duplicate schema work and ensures flawless integration between frontend and backend developers.
99

1010
*If you are new to Neo4j and GraphQL*, take the course https://graphacademy.neo4j.com/courses/graphql-basics/?ref=docs[Introduction to Neo4j & GraphQL] in GraphAcademy to learn the fundamentals, how to use the xref:getting-started/toolbox.adoc[Neo4j GraphQL Toolbox] and the Neo4j GraphQL Library to create GraphQL APIs backed by a Neo4j graph database.
1111

@@ -36,8 +36,8 @@ For every query and mutation that is executed against this generated schema, the
3636

3737
== Interaction
3838

39-
In the xref::getting-started/index.adoc[Getting Started] guide, Apollo Server is used to host the GraphQL schema, so you can interact directly with your API with no front end.
40-
In case you prefer to use front-end frameworks, these are some clients that interact with GraphQL APIs:
39+
In the xref::getting-started/index.adoc[Getting Started] guide, Apollo Server is used to host the GraphQL schema, so you can interact directly with your API with no frontend.
40+
In case you prefer to use frontend frameworks, these are some clients that interact with GraphQL APIs:
4141

4242
- https://reactjs.org/[React] - support through https://www.apollographql.com/docs/react/[Apollo Client]
4343
- https://vuejs.org/[Vue.js] - support through https://apollo.vuejs.org/[Vue Apollo]

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

Lines changed: 56 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,45 @@
1-
[[queries-aggregations]]
1+
[[aggregations]]
2+
:description: This page describes aggregations supported by Neo4j GraphQL.
23
= Aggregations
34

4-
Neo4j GraphQL supports aggregations on fields with type:
5+
Based on the given <<queries-aggregations/index.adoc#examples-reference, type definitions>>, here is a list of fields that accept aggregations supported by Neo4j GraphQL:
56

6-
1. `ID`- String
7-
2. `String` - String
8-
3. `Int` - Numerical
9-
4. `Float` - Numerical
10-
5. `BigInt` - Numerical
11-
6. `DateTime`
12-
7. `Time`
13-
8. `LocalTime`
14-
9. `LocalDateTime`
15-
10. `Duration`
16-
17-
Numerical Fields will expose the following aggregation selections:
18-
19-
1. `min`
20-
2. `max`
21-
3. `average`
22-
4. `sum`
23-
24-
String fields will expose:
25-
26-
1. `shortest`
27-
2. `longest`
28-
29-
The rest will only expose:
30-
31-
1. `min`
32-
2. `max`
33-
34-
35-
Aggregation queries accepts a `where` argument for xref::queries-aggregations/filtering.adoc[filtering] data.
36-
37-
== Counting Using aggregation
38-
39-
The following Query will count all User nodes:
7+
[cols="1,1,2"]
8+
|===
9+
| Type | Aggregating function | Example
4010

11+
| String (e.g. `ID`, `String`)
12+
| `shortest`, `longest`
13+
a|
14+
.Longest User name
4115
[source, graphql, indent=0]
4216
----
4317
query {
4418
usersAggregate {
45-
count
46-
}
47-
}
48-
----
49-
50-
== Counting User nodes where name starts with "J"
51-
52-
[source, graphql, indent=0]
53-
----
54-
query {
55-
usersAggregate(where: { name_STARTS_WITH: "J" }) {
56-
count
19+
name {
20+
longest
21+
}
5722
}
5823
}
5924
----
6025

61-
== Querying for the longest User name
62-
26+
| Numeric (e.g. `Int`, `Float`, `BigInt`)
27+
| `min`, `max`, `average`, `sum`
28+
a|
29+
.Example query
6330
[source, graphql, indent=0]
6431
----
6532
query {
6633
usersAggregate {
67-
name {
68-
longest
69-
}
34+
7035
}
7136
}
72-
----
73-
74-
== Querying for first Post date
37+
----
7538
39+
| Temporal (e.g. `DateTime`, `Time`, `LocalTime`, `LocalDateTime`, `Duration`)
40+
| `min`, `max`
41+
a|
42+
.First Post date
7643
[source, graphql, indent=0]
7744
----
7845
query {
@@ -83,17 +50,41 @@ query {
8350
}
8451
}
8552
----
53+
|===
54+
55+
[NOTE]
56+
====
57+
The argument `where` can also be used in aggregation queries for xref::queries-aggregations/filtering.adoc[filtering] data.
58+
====
8659
87-
[[queries-aggregate-related-nodes]]
8860
== Aggregate related nodes
8961
9062
Related nodes can also be aggregated within a query by accessing the aggregation fields in the node.
9163
In these fields, you can **count**, aggregate the **nodes** or **edges** fields.
9264
9365
The same selections and types as before are available in relationship aggregations.
9466
95-
=== Counting all posts per users
67+
.Counting User nodes
68+
[source, graphql, indent=0]
69+
----
70+
query {
71+
usersAggregate {
72+
count
73+
}
74+
}
75+
----
76+
77+
.Counting User nodes where name starts with "J"
78+
[source, graphql, indent=0]
79+
----
80+
query {
81+
usersAggregate(where: { name_STARTS_WITH: "J" }) {
82+
count
83+
}
84+
}
85+
----
9686
87+
.Counting all posts per User
9788
[source, graphql, indent=0]
9889
----
9990
query {
@@ -106,9 +97,9 @@ query {
10697
}
10798
----
10899
109-
=== Finding longest post per user
110-
By using the `node` field, related nodes properties can be aggregated.
100+
By using the `node` field, related nodes properties can be aggregated:
111101
102+
.Finding longest post per User
112103
[source, graphql, indent=0]
113104
----
114105
query {
@@ -125,9 +116,11 @@ query {
125116
}
126117
----
127118
128-
=== Aggregate relationships
129-
Relationship properties can be aggregated as well by using the `edge` field.
119+
== Aggregate relationships
120+
121+
Relationship properties can be aggregated as well by using the `edge` field:
130122
123+
.Querying what User nodes posted up to a date
131124
[source, graphql, indent=0]
132125
----
133126
query {
@@ -144,10 +137,8 @@ query {
144137
}
145138
----
146139
147-
=== Undirected aggregation queries
148-
149140
When performing an aggregation on related nodes, the query against the relationship
150-
can be defined as an xref::queries-aggregations/queries.adoc#_undirected_queries[undirected] using the argument `directed: false`:
141+
can be defined as "undirected" by using the argument `directed: false`:
151142
152143
[source, graphql, indent=0]
153144
----

0 commit comments

Comments
 (0)