@@ -17,12 +17,10 @@ the GraphQL Java team. It aims to be the foundation for all Spring, GraphQL appl
17
17
Please, use our https://github.com/spring-projects/spring-graphql/issues[issue tracker]
18
18
to report a problem, discuss a design issue, or to request a feature.
19
19
20
- Please, see our
21
- https://github.com/spring-projects/spring-graphql/wiki[Wiki].
20
+ Check the https://github.com/spring-projects/spring-graphql/wiki[Wiki].
22
21
for what's new, baseline requirements, and upgrade notes, and other cross-version information.
23
22
24
- To get started, check the Spring GraphQL starter on https://start.spring.io.
25
- The are also https://github.com/spring-projects/spring-graphql/tree/1.0.x/samples[samples] in the 1.0.x branch, which will be https://github.com/spring-projects/spring-graphql/issues/208[moved out] into a separate repository.
23
+ To get started, see the <<boot-starter>> and <<samples>> sections.
26
24
27
25
28
26
@@ -53,7 +51,7 @@ is also supported, as described in the specification.
53
51
54
52
`GraphQlHttpHandler` can be exposed as an HTTP endpoint by declaring a `RouterFunction`
55
53
bean and using the `RouterFunctions` from Spring MVC or WebFlux to create the route. The
56
- Boot starter does this, see the
54
+ <<boot- starter>> does this, see the
57
55
{spring-boot-ref-docs}/web.html#web.graphql.transports.http-websocket[Web Endpoints] section for
58
56
details, or check `GraphQlWebMvcAutoConfiguration` or `GraphQlWebFluxAutoConfiguration`
59
57
it contains, for the actual config.
@@ -96,7 +94,7 @@ https://github.com/enisdenjo/graphql-ws#recipes[recipes] for client use.
96
94
97
95
`GraphQlWebSocketHandler` can be exposed as a WebSocket endpoint by declaring a
98
96
`SimpleUrlHandlerMapping` bean and using it to map the handler to a URL path. By default,
99
- the Boot starter does not expose a GraphQL over WebSocket endpoint, but it's easy to
97
+ the <<boot- starter>> does not expose a GraphQL over WebSocket endpoint, but it's easy to
100
98
enable it by adding a property for the endpoint path. Please, see the
101
99
{spring-boot-ref-docs}/web.html#web.graphql.transports.http-websocket[Web Endpoints]
102
100
section for details, or check the `GraphQlWebMvcAutoConfiguration` or the
@@ -164,7 +162,7 @@ include::code:RequestErrorInterceptor[]
164
162
<3> Update the `ExecutionResult` with the modified errors
165
163
166
164
Use `WebGraphQlHandler` to configure the `WebGraphQlInterceptor` chain. This is supported
167
- by the Boot starter, see
165
+ by the <<boot- starter>> , see
168
166
{spring-boot-ref-docs}/web.html#web.graphql.transports.http-websocket[Web Endpoints].
169
167
170
168
@@ -195,21 +193,18 @@ The main implementation, `DefaultExecutionGraphQlService`, is configured with a
195
193
196
194
`GraphQlSource` is a contract to expose the `graphql.GraphQL` instance to use that also
197
195
includes a builder API to build that instance. The default builder is available via
198
- `GraphQlSource.schemaResourceBuilder()`. The
199
- {spring-boot-ref-docs}/web.html#web.graphql[Spring Boot starter] creates an instance of
200
- this builder and further initializes it as follows:
201
-
202
- - Loads <<execution.graphqlsource.schema-resources, schema files>> from a configurable location.
203
- - Exposes {spring-boot-ref-docs}/application-properties.html#appendix.application-properties.web[properties]
204
- that apply to `GraphQlSource.Builder`.
205
- - Detects <<execution.graphqlsource.runtimewiring-configurer>> beans.
206
- - Detects https://www.graphql-java.com/documentation/instrumentation[Instrumentation] beans for
207
- {spring-boot-ref-docs}/actuator.html#actuator.metrics.supported.spring-graphql[GraphQL metrics].
208
- - Detects `DataFetcherExceptionResolver` beans for <<execution.exceptions, exception resolution>>.
209
- - Detects `SubscriptionExceptionResolver` beans for <<execution.exceptions.subscription, subscription exception resolution>>.
210
-
211
- For further customizations, you can declare a `GraphQlSourceBuilderCustomizer` bean. For example, to
212
- configure your own `ExecutionIdProvider`:
196
+ `GraphQlSource.schemaResourceBuilder()`.
197
+
198
+ The <<boot-starter>> creates an instance of this builder and further initializes it
199
+ to <<execution.graphqlsource.schema-resources, load schema files>> from a configurable location,
200
+ to {spring-boot-ref-docs}/application-properties.html#appendix.application-properties.web[expose properties]
201
+ to apply to `GraphQlSource.Builder`, to detect
202
+ <<execution.graphqlsource.runtimewiring-configurer>> beans,
203
+ https://www.graphql-java.com/documentation/instrumentation[Instrumentation] beans for
204
+ {spring-boot-ref-docs}/actuator.html#actuator.metrics.supported.spring-graphql[GraphQL metrics],
205
+ and `DataFetcherExceptionResolver` and `SubscriptionExceptionResolver` beans for
206
+ <<execution.exceptions, exception resolution>>. For further customizations, you can also
207
+ declare a `GraphQlSourceBuilderCustomizer` bean, for example:
213
208
214
209
[source,java,indent=0,subs="verbatim,quotes"]
215
210
----
@@ -234,7 +229,7 @@ class GraphQlConfig {
234
229
parsed and merged together. That means schema files can be loaded from just about any
235
230
location.
236
231
237
- By default, the Spring Boot starter
232
+ By default, the Boot starter
238
233
{spring-boot-ref-docs}/web.html#web.graphql.schema[looks for schema files] with extensions
239
234
".graphqls" or ".gqls" under the location `classpath:graphql/**`, which is typically
240
235
`src/main/resources/graphql`. You can also use a file system location, or any location
@@ -297,14 +292,14 @@ You can use `RuntimeWiringConfigurer` to register:
297
292
<<execution.graphqlsource.default-type-resolver>> for a type.
298
293
- `DataFetcher` for a field, although most applications will simply configure
299
294
`AnnotatedControllerConfigurer`, which detects annotated, `DataFetcher` handler methods.
300
- The Spring Boot starter adds the `AnnotatedControllerConfigurer` by default.
295
+ The <<boot- starter>> adds the `AnnotatedControllerConfigurer` by default.
301
296
302
297
NOTE: GraphQL Java, server applications use Jackson only for serialization to and from maps of data.
303
298
Client input is parsed into a map. Server output is assembled into a map based on the field selection set.
304
299
This means you can't rely on Jackson serialization/deserialization annotations.
305
300
Instead, you can use https://www.graphql-java.com/documentation/scalars/[custom scalar types].
306
301
307
- The Spring Boot starter detects beans of type `RuntimeWiringConfigurer` and
302
+ The <<boot- starter>> detects beans of type `RuntimeWiringConfigurer` and
308
303
registers them in the `GraphQlSource.Builder`. That means in most cases, you'll' have
309
304
something like the following in your configuration:
310
305
@@ -402,7 +397,7 @@ and handle directives. For more details, see
402
397
GraphQL Java documentation.
403
398
404
399
In Spring GraphQL you can register a `SchemaDirectiveWiring` through a
405
- <<execution.graphqlsource.runtimewiring-configurer>>. The Spring Boot starter detects
400
+ <<execution.graphqlsource.runtimewiring-configurer>>. The <<boot- starter>> detects
406
401
such beans, so you might have something like:
407
402
408
403
[source,java,indent=0,subs="verbatim,quotes"]
@@ -623,7 +618,7 @@ public class MyConfig {
623
618
}
624
619
----
625
620
626
- The Spring Boot starter declares a `BatchLoaderRegistry` bean that you can inject into
621
+ The <<boot- starter>> declares a `BatchLoaderRegistry` bean that you can inject into
627
622
your configuration, as shown above, or into any component such as a controller in order
628
623
register batch loading functions. In turn the `BatchLoaderRegistry` is injected into
629
624
`DefaultExecutionGraphQlService` where it ensures `DataLoader` registrations per request.
@@ -873,8 +868,7 @@ Auto-registration detects if a given repository implements `QuerydslBinderCustom
873
868
transparently applies that through `QuerydslDataFetcher` builder methods.
874
869
875
870
Auto-registration is performed through a built-in `RuntimeWiringConfigurer` that can be
876
- obtained from `QuerydslDataFetcher`. The
877
- {spring-boot-ref-docs}/web.html#web.graphql.data-query[Boot starter] automatically
871
+ obtained from `QuerydslDataFetcher`. The <<boot-starter>> automatically
878
872
detects `@GraphQlRepository` beans and uses them to initialize the
879
873
`RuntimeWiringConfigurer` with.
880
874
@@ -986,8 +980,7 @@ of the repository domain type. If needed, you can use the `typeName` attribute o
986
980
`@GraphQlRepository` to specify the target GraphQL type name.
987
981
988
982
Auto-registration is performed through a built-in `RuntimeWiringConfigurer` that can be
989
- obtained from `QueryByExampleDataFetcher`. The
990
- {spring-boot-ref-docs}/web.html#web.graphql.data-query[Boot starter] automatically
983
+ obtained from `QueryByExampleDataFetcher`. The <<boot-starter>> automatically
991
984
detects `@GraphQlRepository` beans and uses them to initialize the
992
985
`RuntimeWiringConfigurer` with.
993
986
@@ -1091,7 +1084,7 @@ class, indicating its role as a data fetching component in a GraphQL application
1091
1084
`AnnotatedControllerConfigurer` detects `@Controller` beans and registers their
1092
1085
annotated handler methods as ``DataFetcher``s via `RuntimeWiring.Builder`. It is an
1093
1086
implementation of `RuntimeWiringConfigurer` which can be added to `GraphQlSource.Builder`.
1094
- The Spring Boot starter automatically declares `AnnotatedControllerConfigurer` as a bean
1087
+ The <<boot- starter>> automatically declares `AnnotatedControllerConfigurer` as a bean
1095
1088
and adds all `RuntimeWiringConfigurer` beans to `GraphQlSource.Builder` and that enables
1096
1089
support for annotated ``DataFetcher``s, see the
1097
1090
{spring-boot-ref-docs}/web.html#web.graphql.runtimewiring[GraphQL RuntimeWiring] section
@@ -1685,10 +1678,36 @@ include::includes/testing.adoc[leveloffset=+1]
1685
1678
1686
1679
1687
1680
1681
+ [[boot-starter]]
1682
+ == Boot Starter
1683
+
1684
+ Spring Boot provides a starter for building GraphQL applications with Spring for GraphQL.
1685
+ For version information, see the
1686
+ https://github.com/spring-projects/spring-graphql/wiki/Spring-for-GraphQL-Versions[Spring for GraphQL Versions] wiki page.
1687
+
1688
+ The easiest way to get started is via https://start.spring.io by selecting
1689
+ "Spring for GraphQL" along with an underlying transport such as Spring MVC of WebFlux over
1690
+ HTTP or WebSocket, or over RSocket. Refer to the
1691
+ https://docs.spring.io/spring-boot/docs/current/reference/html/web.html#web.graphql[Spring for GraphQL Starter]
1692
+ section in the Spring Boot reference for details on supported transports, auto-configuration related
1693
+ features, and more. For testing support, see
1694
+ https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#features.testing.spring-boot-applications.spring-graphql-tests[Auto-Configured GraphQL Tests].
1695
+
1696
+ For further reference, check the following GraphQL related:
1697
+
1698
+ - https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.metrics.supported.spring-graphql[Metrics]
1699
+ - https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#appendix.application-properties.web[Properties]
1700
+ - https://docs.spring.io/spring-boot/docs/current/reference/html/auto-configuration-classes.html#appendix.auto-configuration-classes.core[Auto-Configuration Classes]
1701
+
1702
+
1703
+
1704
+
1688
1705
[[samples]]
1689
1706
== Samples
1690
1707
1691
1708
The 1.0.x branch of this repository contains {github-10x-branch}/samples[sample applications] for various scenarios.
1709
+ Those samples do not exist in the `main` branch and will be
1710
+ https://github.com/spring-projects/spring-graphql/issues/208[moved out] into a separate repository.
1692
1711
1693
1712
You can run those by cloning this repository and running main application classes from your IDE or by typing the following on the command line:
1694
1713
0 commit comments