@@ -67,8 +67,7 @@ locations, e.g. across multiple modules.
67
67
68
68
By default, `GraphQlSource.Builder` uses the GraphQL Java `SchemaGenerator` to create the
69
69
`graphql.schema.GraphQLSchema`. This works for typical use, but if you need to use a
70
- different generator, e.g. for xref:federation.adoc[federation], you can register a
71
- `schemaFactory` callback:
70
+ different generator, you can register a `schemaFactory` callback:
72
71
73
72
[source,java,indent=0,subs="verbatim,quotes"]
74
73
----
@@ -81,24 +80,24 @@ builder.schemaResources(..)
81
80
})
82
81
----
83
82
84
- The xref:request-execution.adoc#execution.graphqlsource[GraphQlSource section] explains how to configure that with Spring Boot.
83
+ See the xref:request-execution.adoc#execution.graphqlsource[GraphQlSource] section for how to configure this with Spring Boot.
85
84
86
- For an example with Apollo Federation, see
87
- https://github.com/apollographql/federation-jvm-spring-example[federation-jvm-spring-example].
85
+ If interested in federation, please see the xref:federation.adoc[Federation] section.
88
86
89
87
90
88
[[execution.graphqlsource.runtimewiring-configurer]]
91
89
=== `RuntimeWiringConfigurer`
92
90
93
- You can use `RuntimeWiringConfigurer` to register:
91
+ A `RuntimeWiringConfigurer` is useful to register the following :
94
92
95
93
- Custom scalar types.
96
- - xref:request-execution.adoc#execution.graphqlsource.directives[Directives] handling code.
97
- - Default xref:request-execution.adoc#execution.graphqlsource.default-type-resolver[`TypeResolver`] for interface and union types.
98
- - `DataFetcher` for a field although applications will typically use xref:controllers.adoc[Annotated Controllers], and
99
- those are detected and registered as ``DataFetcher``s by `AnnotatedControllerConfigurer`,
100
- which is a `RuntimeWiringConfigurer`. The xref:boot-starter.adoc[Boot Starter] automatically registers
101
- `AnnotatedControllerConfigurer`.
94
+ - Code that handles xref:request-execution.adoc#execution.graphqlsource.directives[Directives].
95
+ - Direct `DataFetcher` registrations.
96
+ - and more...
97
+
98
+ TIP: Spring applications typically do not need to perform direct `DataFetcher` registrations.
99
+ Instead, controller method are registered as ``DataFetcher``s via
100
+ `AnnotatedControllerConfigurer`, which is a `RuntimeWiringConfigurer`.
102
101
103
102
NOTE: GraphQL Java, server applications use Jackson only for serialization to and from maps of data.
104
103
Client input is parsed into a map. Server output is assembled into a map based on the field selection set.
@@ -116,15 +115,11 @@ public class GraphQlConfig {
116
115
117
116
@Bean
118
117
public RuntimeWiringConfigurer runtimeWiringConfigurer(BookRepository repository) {
119
-
120
118
GraphQLScalarType scalarType = ... ;
121
119
SchemaDirectiveWiring directiveWiring = ... ;
122
- DataFetcher dataFetcher = QuerydslDataFetcher.builder(repository).single();
123
-
124
120
return wiringBuilder -> wiringBuilder
125
121
.scalar(scalarType)
126
- .directiveWiring(directiveWiring)
127
- .type("Query", builder -> builder.dataFetcher("book", dataFetcher));
122
+ .directiveWiring(directiveWiring);
128
123
}
129
124
}
130
125
----
@@ -160,7 +155,7 @@ classNameTypeResolver.setClassNameExtractor((klass) -> {
160
155
builder.defaultTypeResolver(classNameTypeResolver);
161
156
----
162
157
163
- The xref:request-execution.adoc#execution.graphqlsource[GraphQlSource section] explains how to configure that with Spring Boot.
158
+ See the xref:request-execution.adoc#execution.graphqlsource[GraphQlSource] section for how to configure this with Spring Boot.
164
159
165
160
166
161
[[execution.graphqlsource.directives]]
@@ -342,7 +337,7 @@ builder.schemaResources(..)
342
337
.configureGraphQl(graphQLBuilder -> graphQLBuilder.preparsedDocumentProvider(provider))
343
338
----
344
339
345
- The xref:request-execution.adoc#execution.graphqlsource[GraphQlSource section] explains how to configure that with Spring Boot.
340
+ See the xref:request-execution.adoc#execution.graphqlsource[GraphQlSource] section for how to configure this with Spring Boot.
346
341
347
342
348
343
0 commit comments