You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/ROOT/pages/northwind-api.adoc
+18-35Lines changed: 18 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
[[northwind-api]]
2
-
= Creating an API for the Northwind data set
2
+
= GraphQL modelling for the Northwind data set
3
3
:description: This tutorial builds an API around the Northwind sample data set with the Neo4j GraphQL Library.
4
4
5
-
This tutorial uses the Neo4j GraphQL Library to build an API for the Northwind sample datset.
5
+
This tutorial uses the Neo4j GraphQL Library to build an API for the Northwind sample dataset.
6
6
7
7
The Northwind set includes but is not limited to data about products, suppliers, orders and customers.
8
8
This model lends itself for a webshop API.
@@ -14,14 +14,16 @@ This model lends itself for a webshop API.
14
14
Refer to link:https://neo4j.com/docs/aura/getting-started/create-instance/[Creating a Neo4j Aura instance].
15
15
. Populate the instance with the Northwind data set.
16
16
+
17
-
[NOTE]
18
-
====
19
17
If you have completed the GraphQL and Aura Console getting started guide and would like to get rid of the example nodes you have created there, run the following in **Query** before populating your data base with the Northwind set:
20
-
18
+
+
21
19
[source,cypher]
22
20
----
23
21
MATCH (n) DETACH DELETE n;
24
22
----
23
+
+
24
+
[CAUTION]
25
+
====
26
+
This Cypher query deletes all data in your database.
25
27
====
26
28
+
27
29
.. In Aura, select **Learning**, then **Beginner** under **Getting started**.
@@ -168,32 +170,17 @@ mutation {
168
170
}
169
171
----
170
172
171
-
To make it generic, pipe the `contactName` from an input into the query and send the request:
173
+
To make it generic, you can use a link:https://graphql.org/learn/queries/#variables[GraphQL variable] to set the contactName dynamically:
Note that the `orderID` is modeled as a UUID and therefore differs from the order IDs on orders that were already part of the Northwind data set.
229
-
The data model could be extended to account for that by keeping track of the order IDs in a separate system, making sure that the IDs are unique.
230
-
231
-
The products, how many of each of them as well as the customer who places the order must be known.
232
-
A shopping basket typically hands this information to the routine that is placing the order:
215
+
To place an order, the customer and product information must already be known or collected.
216
+
A shopping basket can be implemented as follows:
233
217
234
218
[source, javascript, indent=0]
235
219
----
@@ -239,9 +223,8 @@ A shopping basket typically hands this information to the routine that is placin
239
223
240
224
=== Calculate prices for orders
241
225
242
-
Calculating the price of an order is achieved by accessing the `unitPrice` and `quantity` fields of the products that share the `ORDERS` relationship with the order.
243
-
244
-
Retrieve an order by its ID as well as the products associated with it:
226
+
To calculate order prices, query the `order` operation field and filter the orders by using the `orderID` filter.
227
+
Then access the relationship properties `quantity` and `unitPrice` from the relationships `ORDERS` that connect the `Order` and the `Product` node:
0 commit comments