Skip to content

Commit 6307df8

Browse files
committed
added section for apollo server in graphql aura
1 parent 416b037 commit 6307df8

File tree

3 files changed

+104
-30
lines changed

3 files changed

+104
-30
lines changed

modules/ROOT/pages/getting-started/graphql-aura.adoc

Lines changed: 101 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Even with just field suggestions enabled, it is possible for a malicious actor t
2626

2727
=== Type definitions
2828

29-
Write or paste your **Type definitions**, for example:
29+
Paste these **Type definitions**:
3030
+
3131
[source, graphql, indent=0]
3232
----
@@ -55,13 +55,12 @@ If you are using GraphQL Federation then make sure to select **Enable GraphQL su
5555
To use your GraphQL API with a browser-based application, add an entry in your Cross-Origin Resource Sharing (CORS) policy.
5656
CORS is a browser-based security mechanism that prevents web pages from accessing resources from a server with a different origin.
5757

58-
Add the URL `http://localhost:4000/` to the **Origin** box to enable the use of https://studio.apollographql.com/[Apollo Studio].
59-
If you need multiple entries, select **Add allowed origin**.
58+
Add the URL `https://studio.apollographql.com` to the **Origin** box to enable the use of https://studio.apollographql.com/[Apollo Studio].
59+
If you need more entries, **Add allowed origin** for those.
6060

6161
[NOTE]
6262
====
6363
The URL entered in the CORS policy must be an exact match.
64-
`http://localhost` is not the same as `http://localhost:4000/`.
6564
Wildcards are not supported.
6665
====
6766

@@ -71,13 +70,10 @@ Wildcards are not supported.
7170
All requests to the GraphQL API are authenticated and there are two options for the type of authentication: API key or JSON Web Key Set (JWKS).
7271
It is possible to use these in combination and have multiples of each.
7372

74-
Select an authentication provider from the dropdown list and enter a name.
73+
Select **API Key** from the dropdown list and enter a name.
7574

76-
The API key will be shown after the GraphQL API key has been created, see below.
77-
If you are using JWKS, provide a name and the URL from your identity provider that is used to verify JWKS tokens.
75+
The API key will be shown after the GraphQL API key has been created.
7876

79-
Add more more providers via **Add authentication provider**.
80-
Remove authentication providers via the trash icon.
8177

8278
[CAUTION]
8379
====
@@ -94,46 +90,36 @@ Sizing a GraphQL API is based on the size and complexity of the type definitions
9490
Larger sizes have a higher hourly cost.
9591
If the cost is not displayed, refer to the agreement you have with Neo4j.
9692

97-
Select **Create** to proceed and create the GraphQL API.
98-
9993

10094
== API key
10195

102-
If you chose to use an API key with the GraphQL API it is now displayed.
96+
**Create** the GraphQL API.
97+
98+
Your API key is now displayed.
10399
Store this information securely as it cannot be retrieved again.
104-
Select **I understand** and then **Close** once you have done this.
100+
Confirm with **I understand** and **Close**.
105101

106-
The GraphQL API will now be provisioned.
102+
The GraphQL API will be provisioned.
107103
You can see the status via **Data APIs** from the left side navigation.
108-
When the status changes to "Ready", the API is ready to use.
109-
If it has a status of 'Error', use the three dots icon and **Edit** from the menu to change the configuration.
110104

111105

112-
== Usage
106+
== Create nodes in the database
113107

114108
When the status for the GraphQL API is "Ready" you can send GraphQL requests to it.
115-
As all requests are subject to authentication, you must include an API key or JWT token.
109+
As all requests are subject to authentication, you must include the API key.
116110

117-
With cURL, requests have the following format:
118111

119-
[source, bash, indent=0]
120-
----
121-
curl --location <YOUR_GRAPHQL_API_URL> --header 'Content-Type: application/json' --header 'x-api-key: <YOUR_API_KEY>' --data '<YOUR_GRAPHQL_QUERY>'
122-
----
112+
=== Via cURL
123113

124114
[source, bash, indent=0]
125115
----
126-
curl --location <YOUR_GRAPHQL_API_URL> --header 'Authorization: Bearer <YOUR_JWT>'--header 'Content-Type: application/json --data '<YOUR_GRAPHQL_QUERY>'
116+
curl --location <YOUR_GRAPHQL_API_URL> --header 'Content-Type: application/json' --header 'x-api-key: <YOUR_API_KEY>' --data '<YOUR_GRAPHQL_QUERY>'
127117
----
128118

129-
130-
=== Create nodes in the database
131-
132119
On the command line, execute:
133120

134121
[source, bash, indent=0]
135122
----
136-
curl --location --header 'Content-Type: application/json' --header 'x-api-key: <YOUR_API_KEY>' --data '<YOUR_GRAPHQL_QUERY>'
137123
curl --location <YOUR_GRAPHQL_API_URL> --header 'Content-Type: application/json' --header 'x-api-key: <YOUR_API_KEY>' --data '{ "query": "mutation { createProducts( input: [ { productName: \"New Product\" category: { create: [{ node: { categoryName: \"New Category\" } }] } } ] ) { products { productName category { categoryName } } }}" }'
138124
----
139125

@@ -151,6 +137,93 @@ You should see this:
151137
{"data":{"products":[{"productName":"New Product","category":[{"categoryName":"New Category"}]}]}}
152138
----
153139

140+
141+
=== Via Apollo Server
142+
143+
. On the https://studio.apollographql.com/[Apollo Studio] website, paste your GraphQL Data API URL to the **Sandbox** input.
144+
. Use the cog icon and add `x-api-key` and the API key for your data API under **Shared headers** and **Save**.
145+
. To start adding data, copy and paste the following mutation to the **Operation** panel to create a product and category in that product:
146+
+
147+
[source, graphql, indent=0]
148+
----
149+
mutation {
150+
createProducts(
151+
input: [
152+
{
153+
productName: "New Product"
154+
category: { create: [{ node: { categoryName: "New Category" } }] }
155+
}
156+
]
157+
) {
158+
products {
159+
productName
160+
category {
161+
categoryName
162+
}
163+
}
164+
}
165+
}
166+
----
167+
168+
. Use **Run** on the top right.
169+
You should get the following confirmation that the data has been created in the database in the **Response** panel:
170+
+
171+
[source, json, indent=0]
172+
----
173+
{
174+
"data": {
175+
"createProducts": {
176+
"products": [
177+
{
178+
"productName": "New Product",
179+
"category": [
180+
{
181+
"categoryName": "New Category"
182+
}
183+
]
184+
}
185+
]
186+
}
187+
}
188+
}
189+
----
190+
191+
. Query the data you just added.
192+
Copy and paste the following query to the **Operations** panel:
193+
+
194+
[source, graphql, indent=0]
195+
----
196+
query {
197+
products {
198+
productName
199+
category {
200+
categoryName
201+
}
202+
}
203+
}
204+
----
205+
+
206+
Since you only created one "Product" node and one "Category" node, the **Response** panel shows the following:
207+
+
208+
[source, json, indent=0]
209+
----
210+
{
211+
"data": {
212+
"products": [
213+
{
214+
"productName": "New Product",
215+
"category": [
216+
{
217+
"categoryName": "New Category"
218+
}
219+
]
220+
}
221+
]
222+
}
223+
}
224+
----
225+
226+
154227
This concludes the tutorial.
155228
You now have a GraphQL Data API connected to a Neo4j AuraDB and you have added two nodes.
156229

modules/ROOT/pages/getting-started/graphql-self-hosted.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ The address http://localhost:4000/ is the URL where the Apollo Server starts.
192192
You should get redirected to the Apollo Sandbox.
193193

194194
. At the moment your database is empty.
195-
To start adding data, copy and paste the following mutation to the **Operation** panel to create a movie and an actor in that movie:
195+
To start adding data, copy and paste the following mutation to the **Operation** panel to create a product and a category in that product:
196196
+
197197
[source, graphql, indent=0]
198198
----

modules/ROOT/pages/getting-started/toolbox.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ With it, you can:
1212
. Build the Neo4j GraphQL schema.
1313
. Experiment, query, and play.
1414

15+
1516
== Connect to a Neo4j database
1617

1718
Before you start using the Toolbox, make sure you have followed all xref:index.adoc#_requirements[requirements] to run a Neo4j database.
@@ -21,7 +22,7 @@ You can use https://neo4j.com/docs/desktop-manual/current/[Neo4j Desktop] or htt
2122

2223
. Set your type definitions directly in the Toolbox editor or introspect the Neo4j database you connected to.
2324
+
24-
If you followed one of the xref:getting-started/index.adoc[Getting started tutorials], you should see these type definitions in the GraphQL Toolbox:
25+
If you followed the xref:getting-started/graphql-self-hosted.adoc[self-hosted GraphQL tutorial], you should see these type definitions in the GraphQL Toolbox:
2526
+
2627
[source, graphql, indent=0]
2728
----

0 commit comments

Comments
 (0)