Skip to content

Commit 844d5da

Browse files
committed
added page for northwind api
1 parent eef3ac0 commit 844d5da

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-1
lines changed

modules/ROOT/content-nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
* *How-To*
5454
5555
* xref:driver-configuration.adoc[]
56+
* xref:northwind-api.adoc[]
5657
5758
* *Products*
5859
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
[[northwind-api]]
2+
= Creating an API for the Northwind dataset
3+
:description: This tutorial builds an API around the Northwind sample dataset with the Neo4j GraphQL Library.
4+
5+
This tutorial uses the Neo4j GraphQL Library to build an API for the Northwind sample datset.
6+
7+
The Northwind set includes but is not limited to data about products, suppliers, orders and customers.
8+
This model lends itself for a webshop API.
9+
10+
11+
== Prerequisites
12+
13+
. Set up a new AuraDB instance.
14+
Refer to link:https://neo4j.com/docs/aura/getting-started/create-instance/[Creating a Neo4j Aura instance].
15+
. Populate the instance with the Northwind dataset.
16+
.. In Aura, select **Learning**, then **Beginner** under **Getting started**.
17+
.. Select the **Learn the basics** tile and scroll to page 4/11 in the left side menu.
18+
.. Trigger the import with **Get the Northwind datset** and then **Run import** on the right hand side.
19+
20+
[NOTE]
21+
====
22+
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**:
23+
24+
[source,cypher]
25+
----
26+
MATCH (n) DETACH DELETE n;
27+
----
28+
====
29+
30+
31+
== Goal
32+
33+
A webshop API which connects to the Northwind dataset should be able to:
34+
35+
* Create new customers
36+
* Place orders
37+
* Calculate prices for orders
38+
* Filter products by supplier and category
39+
40+
41+
== Type definitions
42+
43+
First, make the nodes and relationships from xref:#_goal[] available:
44+
45+
[source, graphql, indent=0]
46+
----
47+
type Customer @node {
48+
contactName: String!
49+
orders: [Order!]! @relationship(type: "PURCHASED", direction: OUT)
50+
}
51+
52+
type Order @node {
53+
orderID: Int!
54+
customer: [Customer!]! @relationship(type: "PURCHASED", direction: IN)
55+
products: [Product!]! @relationship(type: "ORDERS", direction: OUT)
56+
}
57+
58+
type Product @node {
59+
productName: String!
60+
category: [Category!]! @relationship(type: "PART_OF", direction: OUT)
61+
orders: [Product!]! @relationship(type: "ORDERS", direction: IN)
62+
supplier: [Supplier!]! @relationship(type: "SUPPLIES", direction: IN)
63+
}
64+
65+
type Category @node {
66+
categoryName: String!
67+
products: [Product!]! @relationship(type: "PART_OF", direction: IN)
68+
}
69+
70+
type Supplier @node {
71+
supplierID: Int!
72+
companyName: String!
73+
products: [Product!]! @relationship(type: "SUPPLIES", direction: OUT)
74+
}
75+
76+
type ordersProperties @relationshipProperties {
77+
unitPrice: Float!
78+
quantity: Int!
79+
}
80+
----
81+

modules/ROOT/pages/types/relationships.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ type Person @node {
147147
----
148148

149149
`queryDirection` can have the following values:
150+
150151
* `DIRECTED`: only directed queries can be performed on this relationship.
151152
* `UNDIRECTED`: only undirected queries can be performed on this relationship.
152153

@@ -335,4 +336,4 @@ type Post @node {
335336
----
336337

337338
The relationship at `User.posts` is considered a "many" relationship, which means it should always be of type `NonNullListType` and `NonNullNamedType`.
338-
In other words, both the array and the type inside of a "many" relationship should have a `!`.
339+
In other words, both the array and the type inside of a "many" relationship must have a `!`.

0 commit comments

Comments
 (0)