@@ -284,29 +284,23 @@ The main implementation, `DefaultExecutionGraphQlService`, is configured with a
284
284
[[execution-graphqlsource]]
285
285
=== `GraphQLSource`
286
286
287
- `GraphQlSource` is a core Spring abstraction for access to the
288
- `graphql.GraphQL` instance to use for request execution. It provides a builder API to
289
- initialize GraphQL Java and build a `GraphQlSource`.
290
-
291
- The default `GraphQlSource` builder, accessible via
292
- `GraphQlSource.schemaResourceBuilder()`, enables support for
293
- <<execution-reactive-datafetcher>>, <<execution-context>>, and <<execution-exceptions>>.
294
-
295
- The Spring Boot {spring-boot-ref-docs}/web.html#web.graphql[starter] initializes a
296
- `GraphQlSource` instance through the default `GraphQlSource.Builder` and also enables
297
- the following:
298
-
299
- - Load <<execution-graphqlsource-schema-resources, schema files>> from a configurable location.
300
- - Expose {spring-boot-ref-docs}/application-properties.html#appendix.application-properties.web[properties]
287
+ `GraphQlSource` is a contract to expose the `graphql.GraphQL` instance to use that also
288
+ includes a builder API to build that instance. The default builder is available via
289
+ `GraphQlSource.schemaResourceBuilder()`. The
290
+ {spring-boot-ref-docs}/web.html#web.graphql[Spring Boot starter] creates an instance of
291
+ this builder and further initializes it as follows:
292
+
293
+ - Loads <<execution-graphqlsource-schema-resources, schema files>> from a configurable location.
294
+ - Exposes {spring-boot-ref-docs}/application-properties.html#appendix.application-properties.web[properties]
301
295
that apply to `GraphQlSource.Builder`.
302
- - Detect <<execution-graphqlsource-runtimewiring-configurer>> beans.
303
- - Detect https://www.graphql-java.com/documentation/instrumentation[Instrumentation] beans for
296
+ - Detects <<execution-graphqlsource-runtimewiring-configurer>> beans.
297
+ - Detects https://www.graphql-java.com/documentation/instrumentation[Instrumentation] beans for
304
298
{spring-boot-ref-docs}/actuator.html#actuator.metrics.supported.spring-graphql[GraphQL metrics].
305
- - Detect `DataFetcherExceptionResolver` beans for <<execution-exceptions, exception resolution>>.
306
- - Detect `SubscriptionExceptionResolver` beans for <<execution-exceptions-subsctiption, subscription exception resolution>>.
299
+ - Detects `DataFetcherExceptionResolver` beans for <<execution-exceptions, exception resolution>>.
300
+ - Detects `SubscriptionExceptionResolver` beans for <<execution-exceptions-subsctiption, subscription exception resolution>>.
307
301
308
- For further customizations, you can declare your own `GraphQlSourceBuilderCustomizer` beans;
309
- for example, for configuring your own `ExecutionIdProvider`:
302
+ For further customizations, you can declare a `GraphQlSourceBuilderCustomizer` bean. For example, to
303
+ configure your own `ExecutionIdProvider`:
310
304
311
305
[source,java,indent=0,subs="verbatim,quotes"]
312
306
----
@@ -345,9 +339,9 @@ locations, e.g. across multiple modules.
345
339
[[execution-graphqlsource-schema-creation]]
346
340
==== Schema Creation
347
341
348
- By default, `GraphQlSource.Builder` uses the GraphQL Java `GraphQLSchemaGenerator ` to
349
- create the `graphql.schema.GraphQLSchema`. This works for most applications , but if
350
- necessary, you can hook into the schema creation through the builder :
342
+ By default, `GraphQlSource.Builder` uses the GraphQL Java `SchemaGenerator ` to create the
343
+ `graphql.schema.GraphQLSchema`. This works for typical use , but if you need to use a
344
+ different generator, e.g. for federation, you can register a `schemaFactory` callback :
351
345
352
346
[source,java,indent=0,subs="verbatim,quotes"]
353
347
----
@@ -360,10 +354,29 @@ builder.schemaResources(..)
360
354
})
361
355
----
362
356
363
- The primary reason for this is to create the schema through a federation library.
364
-
365
357
The <<execution-graphqlsource, GraphQlSource section>> explains how to configure that with Spring Boot.
366
358
359
+
360
+ [[execution-graphqlsource-schema-traversal]]
361
+ ==== Schema Traversal
362
+
363
+ You can register a `graphql.schema.GraphQLTypeVisitor` via
364
+ `builder.schemaResources(..).typeVisitors(..)` if you want to traverse the schema after
365
+ it is created, and possibly apply changes to the `GraphQLCodeRegistry`. Keep in mind,
366
+ however, that such a visitor cannot change the schema. See
367
+ <<execution-graphqlsource-schema-transformation>>, if you need to make changes to the schema.
368
+
369
+
370
+ [[execution-graphqlsource-schema-transformation]]
371
+ ==== Schema Transformation
372
+
373
+ You can register a `graphql.schema.GraphQLTypeVisitor` via
374
+ `builder.schemaResources(..).typeVisitorsToTransformSchema(..)` if you want to traverse
375
+ and transform the schema after it is created, and make changes to the schema. Keep in mind
376
+ that this is more expensive than <<execution-graphqlsource-schema-traversal>> so generally
377
+ prefer traversal to transformation unless you need to make schema changes.
378
+
379
+
367
380
[[execution-graphqlsource-runtimewiring-configurer]]
368
381
==== `RuntimeWiringConfigurer`
369
382
0 commit comments