Skip to content

Commit 1939021

Browse files
committed
Summarize Boot starter features for GraphQlSource.Builder
Important to mention the `GraphQlSourceBuilderCustomizer` which is otherwise mentioned neither in the Boot starter nor the reference here. It is the path to a number of customizations that are discussed in `GraphQlSource` subsections. See gh-233
1 parent a9cd0a9 commit 1939021

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

spring-graphql-docs/src/docs/asciidoc/index.adoc

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,34 @@ The default `GraphQlSource` builder, accessible via `GraphQlSource.builder()`, e
191191
support for <<execution-reactive-datafetcher>>, <<execution-context>>, and
192192
<<execution-exceptions>>.
193193

194+
The Spring Boot {spring-boot-ref-docs}/web.html#web.graphql[starter] initializes a
195+
`GraphQlSource` instance through the default `GraphQlSource.Builder` and also enables
196+
the following:
197+
198+
- Load <<execution-graphqlsource-schema-resources, schema files>> from a configurable location.
199+
- Expose {spring-boot-ref-docs}/application-properties.html#appendix.application-properties.web[properties]
200+
that apply to `GraphQlSource.Builder`.
201+
- Detect <<execution-graphqlsource-runtimewiring-configurer>> beans.
202+
- Detect `Instrumentation` beans for GraphQL
203+
{spring-boot-ref-docs}/actuator.html#actuator.metrics.supported.spring-graphql[metrics].
204+
- Detect `DataFetcherExceptionResolver` beans for
205+
<<execution-exceptions, exception resolution>>.
206+
- Detect `GraphQlSourceBuilderCustomizer` beans for any other customizations.
207+
208+
194209

195210
[[execution-graphqlsource-schema-resources]]
196211
==== Schema Resources
197212

198213
`GraphQlSource.Builder` can be configured with one or more `Resource` instances to be
199214
parsed and merged together. That means schema files can be loaded from just about any
200-
location. By default, the Spring Boot starter
201-
{spring-boot-ref-docs}/web.html#web.graphql.schema[loads schema files]
202-
from a well-known classpath location, but you can change that to a location on the file
203-
system via `FileSystemResource`, to byte content via `ByteArrayResource`, or implement a
204-
custom `Resource` that loads schema files from a remote location or storage.
215+
location.
216+
217+
By default, the Spring Boot starter
218+
{spring-boot-ref-docs}/web.html#web.graphql.schema[finds schema files] from a
219+
well-known classpath location, but you can change that to a location on the file system
220+
via `FileSystemResource`, to byte content via `ByteArrayResource`, or implement a custom
221+
`Resource` that loads schema files from a remote location or storage.
205222

206223

207224
[[execution-graphqlsource-schema-creation]]
@@ -213,13 +230,14 @@ necessary, you can hook into the schema creation through the builder:
213230

214231
[source,java,indent=0,subs="verbatim,quotes"]
215232
----
216-
GraphQlSource graphQlSource = GraphQlSource.builder()
217-
.schemaResources(..)
233+
// Typically, accessed through Spring Boot's GraphQlSourceBuilderCustomizer
234+
GraphQlSource.Builder builder = ...
235+
236+
builder.schemaResources(..)
218237
.configureRuntimeWiring(..)
219238
.schemaFactory((typeDefinitionRegistry, runtimeWiring) -> {
220239
// create `GraphQLSchema`
221240
})
222-
.build();
223241
----
224242

225243
The primary reason for this is to create the schema through a federation library.
@@ -238,7 +256,7 @@ You can use `RuntimeWiringConfigurer` to register:
238256
`AnnotatedControllerConfigurer`, which detects annotated, `DataFetcher` handler methods.
239257
The Spring Boot starter adds the `AnnotatedControllerConfigurer` by default.
240258

241-
The Spring for GraphQL Boot starter detects beans of type `RuntimeWiringConfigurer` and
259+
The Spring Boot starter detects beans of type `RuntimeWiringConfigurer` and
242260
registers them in the `GraphQlSource.Builder`. That means in most cases, you'll' have
243261
something like the following in your configuration:
244262

0 commit comments

Comments
 (0)