Skip to content

Commit a0d434f

Browse files
authored
Merge pull request #33 from OpenLiberty/sme-review
Address SME review
2 parents 23e187d + f890733 commit a0d434f

File tree

6 files changed

+32
-215
lines changed

6 files changed

+32
-215
lines changed

README.adoc

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ You will learn how to build and use a simple GraphQL service with
3535
https://openliberty.io/docs/latest/reference/feature/mpGraphQL-1.0.html[MicroProfile GraphQL^].
3636

3737
GraphQL is an open source data query language.
38-
Unlike REST APIs, each `POST` request that is sent to a GraphQL service goes to a single HTTP endpoint.
38+
Unlike REST APIs, each HTTP request that is sent to a GraphQL service goes to a single HTTP endpoint.
3939
Create, read, update, and delete operations and their details are differentiated by the contents of the request.
4040
If the operation returns data, the user specifies what properties of the data that they want returned.
4141
For read operations, a JSON object is returned that contains only the data and properties that are specified.
@@ -53,6 +53,11 @@ It can then collate this data into a single object for the user.
5353
This simplifies data retrieval as the user only makes a single request to the GraphQL service,
5454
instead of multiple requests to the individual data sources.
5555

56+
All of the available operations to retrieve or modify data are available in a single GraphQL schema.
57+
The GraphQL schema describes all the data types used in the GraphQL service.
58+
The schema also describes all of the available operations.
59+
As well, you can add names and text descriptions to the various object types and operations in the schema.
60+
5661
You can learn more about GraphQL at the https://graphql.org/[GraphQL website^].
5762

5863
You'll create a GraphQL application that retrieves data from multiple `system` services.
@@ -63,14 +68,14 @@ image::architecture.png[GraphQL architecture where multiple system microservices
6368

6469
The guide application includes an interactive GraphQL tool called
6570
https://github.com/graphql/graphiql/tree/main/packages/graphiql[GraphiQL^].
66-
GraphiQL helps you make queries to a GraphQL service.
71+
GraphiQL helps you make queries to a GraphQL service.
6772
In the GraphiQL UI, you need to type only the body of the query for the purposes of manual tests and examples.
6873

6974
== Additional prerequisites
7075

7176
Before you begin, Docker needs to be installed.
7277
For installation instructions, refer to the https://docs.docker.com/get-docker/[official Docker documentation^].
73-
You will build and run the application in Docker containers.
78+
You'll build and run the application in Docker containers.
7479

7580
Make sure to start your Docker daemon before you proceed.
7681

@@ -89,7 +94,7 @@ Navigate to the `start` directory to begin.
8994

9095
Object types define the structure of the data returned by GraphQL.
9196
Annotations that are applied to the declaration and properties of Java classes define object types.
92-
The object types are defined in their own Maven module which is included in the other modules.
97+
The object types are defined in their own Maven module that is included in the other modules.
9398

9499
[role="code_command hotspot file=0", subs="quotes"]
95100
----
@@ -147,8 +152,8 @@ To save time, the [hotspot=class file=3]`SystemLoad` class and
147152
The `SystemLoad` class maps to the [hotspot=type file=3]`systemLoad`
148153
object type, which describes the resource usage of a `system` service.
149154
The `SystemLoadData` class maps to the [hotspot=type file=4]`loadData` object type.
150-
This will be a nested object inside the `systemLoad` object type.
151-
Together, these will contain the details of the resource usage of a `system` service.
155+
The `loadData` object will be a nested object inside the `systemLoad` object type.
156+
Together, these objects will contain the details of the resource usage of a `system` service.
152157

153158
// file 0
154159
JavaInfo.java
@@ -187,7 +192,12 @@ include::finish/models/src/main/java/io/openliberty/guides/graphql/models/System
187192

188193
== Implementing system service
189194

190-
GraphQL needs a way to access information about the `system` microservices for this example.
195+
The `system` microservices are backend services using JAX-RS.
196+
For more details on using JAX-RS, see our
197+
https://www.openliberty.io/guides/rest-intro.html[Creating a RESTful web service guide^].
198+
This `system` microservices report system properties.
199+
Multiple instances of them will be accessed and their information will be collated by GraphQL.
200+
In a real scenario, GraphQL might access multiple different databases or other services.
191201

192202
[role="code_command hotspot file=0" ,subs="quotes"]
193203
----
@@ -206,7 +216,7 @@ The [hotspot=note file=0]`note` endpoint is used to write a note into the system
206216
`system/src/main/java/io/openliberty/guides/system/SystemManagementResource.java`
207217
----
208218

209-
The [hotspot file=1]`SystemMangaementResource` class provides information on the system's operating system and resource management.
219+
The [hotspot file=1]`SystemManagementResource` class provides information on the system's operating system and resource management.
210220
The [hotspot=operatingSystem file=1]`operatingSystem` endpoint assembles and returns an object describing the operating system.
211221
The [hotspot=systemLoad file=1]`systemLoad` endpoint assembles and returns an object describing the system load.
212222
It will include the JVM heap load and processor load.
@@ -250,10 +260,10 @@ This request is handled by the [hotspot=getSystemInfo file=0]`getSystemInfo()` f
250260
It retrieves and bundles system information into a `SystemInfo` object that is returned.
251261

252262
It uses an [hotspot=getSystemInfoHeader file=0]`@Name` on one of its input parameters.
253-
The `@Name` annotation has different functions depending on the context in which it is used.
263+
The `@Name` annotation has different functions depending on the context in which it's used.
254264
In this context, it denotes input parameters for GraphQL operations.
255265
For the [hotspot=getSystemInfo file=0]`getSystemInfo()` function,
256-
it is used to input the `hostname` for the system you want to look up information for.
266+
it's used to input the `hostname` for the system you want to look up information for.
257267

258268
Recall that the `SystemInfo` class contained nested objects.
259269
It contained a `JavaInfo` and an `OperatingSystem` object.
@@ -276,7 +286,7 @@ Operations of the `mutation` type are be used to edit data.
276286
They can create, update, or delete data.
277287
They're defined by using the [hotspot=mutation file=0]`@Mutation` annotation.
278288

279-
There is one `mutation` operation in this application - the `editNote` request.
289+
There's one `mutation` operation in this application - the `editNote` request.
280290
This request is handled by the [hotspot=editNoteFunction file=0]`editNote()` function.
281291
This request is used to write a note into the properties of a given system.
282292
There are inputs for the system you want to write into, and the note you want to write.
@@ -316,6 +326,8 @@ The Open Liberty server needs to be configured to support the GraphQL query lang
316326
The [hotspot=graphql file=1]`mpGraphQL-1.0` feature that is added to the [hotspot file=1]`server.xml`
317327
enables the use of the https://openliberty.io/docs/latest/reference/feature/mpGraphQL-1.0.html[MicroProfile GraphQL^]
318328
feature in Open Liberty.
329+
Open Liberty's MicroProfile GraphQL feature includes GraphiQL.
330+
Enable it by setting the [hotspot=enableGraphiql file=1]`io.openliberty.enableGraphQLUI` variable to `true`.
319331

320332
// file 0
321333
pom.xml
@@ -384,13 +396,10 @@ The containers may take some time to become available.
384396
== Running GraphQL queries
385397

386398
Before making any requests, visit the http://localhost:9082/graphql/schema.graphql[^] URL.
387-
This URL contains the schema, which describes the GraphQL service.
388-
The schema details what operations are available and any object types that are returned.
389-
Object types described will have their fields and their types listed.
390-
If defined, descriptions of object types and operations will also be included.
399+
This URL returns the schema to describe the GraphQL service.
391400

392401
To access the GraphQL service, GraphiQL has already been set up and included for you.
393-
Access GraphiQL at the http://localhost:9082/graphiql.html[^] URL.
402+
Access GraphiQL at the http://localhost:9082/graphql-ui[^] URL.
394403
Queries that are made through GraphiQL are the same as queries that are made through HTTP requests.
395404
You can also view the schema through GraphiQL by clicking the `Docs` button on the menu bar.
396405

@@ -454,7 +463,7 @@ mutation {
454463

455464
You receive a response containing the Boolean `true` to let you know that the request was successfully processed.
456465
You can see the note that you added by running the following query operation.
457-
Notice that there is no need to run a full query, as you only want the `note` property.
466+
Notice that there's no need to run a full query, as you only want the `note` property.
458467
Thus, the request only contains the `note` property.
459468

460469
[role='command']

finish/graphql/src/main/liberty/config/server.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
<variable name="default.http.port" defaultValue="9082"/>
1414
<variable name="default.https.port" defaultValue="9445"/>
1515

16+
<!-- tag::enableGraphiql[] -->
17+
<variable name="io.openliberty.enableGraphQLUI" value="true" />
18+
<!-- end::enableGraphiql[] -->
19+
1620
<webApplication location="graphql.war" contextRoot="/" />
1721
<httpEndpoint host="*" httpPort="${default.http.port}"
1822
httpsPort="${default.https.port}" id="defaultHttpEndpoint"/>

finish/graphql/src/main/webapp/graphiql.html

Lines changed: 0 additions & 98 deletions
This file was deleted.

finish/graphql/src/main/webapp/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ <h2>GraphQL service</h2>
2525
</p>
2626
<p>
2727
Access GraphiQL at the
28-
<a href="/graphiql.html" target="_blank" rel="noopener noreferrer">/graphiql.html</a>.
28+
<a href="/graphql-ui" target="_blank" rel="noopener noreferrer">/graphql-ui</a>.
2929
</p>
3030
</div>
3131
<div>

start/graphql/src/main/webapp/graphiql.html

Lines changed: 0 additions & 98 deletions
This file was deleted.

start/graphql/src/main/webapp/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ <h2>GraphQL service</h2>
2525
</p>
2626
<p>
2727
Access GraphiQL at the
28-
<a href="/graphiql.html" target="_blank" rel="noopener noreferrer">/graphiql.html</a>.
28+
<a href="/graphql-ui" target="_blank" rel="noopener noreferrer">/graphql-ui</a>.
2929
</p>
3030
</div>
3131
<div>

0 commit comments

Comments
 (0)