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/index.adoc
+39-34Lines changed: 39 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,43 +5,14 @@
5
5
6
6
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.
7
7
8
-
== How it works
9
-
10
-
Here is an example of how you can query existing data:
11
8
12
-
[source, graphql, indent=0]
13
-
----
14
-
query {
15
-
products {
16
-
productName
17
-
category {
18
-
categoryName
19
-
}
20
-
}
21
-
}
22
-
----
9
+
== How it works
23
10
24
-
The response looks like this:
11
+
The Neo4j GraphQL Library requires a set of type definitions that describes the shape of your graph data and creates an API layer to communicate with the data.
25
12
26
-
[source, json, indent=0]
27
-
----
28
-
{
29
-
"data": {
30
-
"products": [
31
-
{
32
-
"productName": "New Product",
33
-
"category": [
34
-
{
35
-
"categoryName": "New Category"
36
-
}
37
-
]
38
-
}
39
-
]
40
-
}
41
-
}
42
-
----
13
+
It generates an entire executable schema with all additional types needed to execute queries and mutations to interact with your Neo4j database.
43
14
44
-
For the example query to work, the library requires the following type definitions:
15
+
For example, consider these type definitions:
45
16
46
17
[source, graphql, indent=0]
47
18
----
@@ -58,7 +29,7 @@ type Category @node {
58
29
59
30
Based on these type definitions, the library generates query and mutation templates to create new instances of the types as well as query existing instances.
60
31
61
-
The following mutation creates the new product and the new category which were queried above:
32
+
The following mutation creates a new product as well as a new category:
62
33
63
34
[source, graphql, indent=0]
64
35
----
@@ -81,6 +52,40 @@ mutation {
81
52
}
82
53
----
83
54
55
+
Here is an example of how you can query existing data:
56
+
57
+
[source, graphql, indent=0]
58
+
----
59
+
query {
60
+
products {
61
+
productName
62
+
category {
63
+
categoryName
64
+
}
65
+
}
66
+
}
67
+
----
68
+
69
+
The response looks like this:
70
+
71
+
[source, json, indent=0]
72
+
----
73
+
{
74
+
"data": {
75
+
"products": [
76
+
{
77
+
"productName": "New Product",
78
+
"category": [
79
+
{
80
+
"categoryName": "New Category"
81
+
}
82
+
]
83
+
}
84
+
]
85
+
}
86
+
}
87
+
----
88
+
84
89
For every query and mutation that is executed against this generated schema, the Neo4j GraphQL Library generates a single Cypher query which is executed against the database.
85
90
This eliminates the https://www.google.com/search?q=graphql+n%2B1[N+1 Problem], which can make GraphQL implementations slow and inefficient.
0 commit comments