Skip to content

Commit 9ff6bae

Browse files
committed
Update section on codegen
See gh-848
1 parent 6cd3e42 commit 9ff6bae

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

Diff for: spring-graphql-docs/src/docs/asciidoc/codegen.adoc

+14-16
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@ You can use tools such as
99
https://netflix.github.io/dgs/generating-code-from-schema/[DGS Code Generation] to generate
1010
Java types from the GraphQL schema. The following can be generated:
1111

12-
1. Client types for requests (e.g. queries, mutations) input types, and other types to
13-
express the response selection set.
14-
2. Data types.
15-
3. Server handling classes (e.g. controllers).
12+
1. Client types for requests (e.g. queries, mutations) input types, and response selection types.
13+
2. Data types corresponding to GraphQL schema types.
1614

17-
Code generation provides convenience initially, but is not ideal for your own application
18-
domain types over which you'll typically want control. For client types, however, code
19-
generation can be very useful since you typically don't need to manually change generated
20-
request types, input types, and selection set types. Response types could be imported,
21-
if you have access to them, or otherwise could also be generated.
15+
Code generation may not be ideal for your own application's data types especially if you
16+
want to add logic to them. Code generation, however, is a good fit for client types since
17+
those define the request, and don't need to have other logic. As a client, you may also
18+
choose to generate the data types for the response.
2219

2320
Client generated types can be used with Spring's `GraphQlClient`. Start by following the
2421
instructions for the DGS code generation plugin to generate client API types. Then, given
@@ -36,9 +33,8 @@ a schema like this:
3633
}
3734
----
3835

39-
DGS Codegen will generate a `BooksGraphQLQuery` and `BooksProjectionRoot` classes.
40-
You can then use those with Spring's `GraphQlClient` along with your own `Book` class
41-
for the response:
36+
DGS Codegen generates `BooksGraphQLQuery` and `BooksProjectionRoot` that you can use with
37+
`GraphQlClient` over HTTP (or any supported transport) as follows:
4238

4339
[source,java,indent=0,subs="verbatim,quotes"]
4440
----
@@ -50,10 +46,12 @@ for the response:
5046
5147
List<Book> books = client.document(document)
5248
.retrieve(query.getOperationName())
53-
.toEntityList(Book.class)
49+
.toEntityList(Book.class) // possibly also generated or imported if available
5450
.block();
5551
----
5652

57-
NOTE: Spring Initializer at https://start.spring.io is scheduled to add support for the DGS
58-
Code Generation with Gradle and Maven. See
59-
https://github.com/spring-io/start.spring.io/pull/1348[start.spring.io#1348].
53+
TIP: We intend to further simplify the above code in
54+
https://github.com/spring-projects/spring-graphql/issues/846[spring-graphql#846].
55+
56+
You can use Spring Initializer at https://start.spring.io to create a Spring project with
57+
the DGS Code Generation Gradle or Maven plugin.

0 commit comments

Comments
 (0)