Skip to content

Commit afb0b64

Browse files
committed
Add section on directives in reference docs
Closes gh-262
1 parent 194126d commit afb0b64

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
:github-issues: https://github.com/{github-repo}/issues/
1414
:github-main-branch: https://github.com/{github-repo}/tree/main
1515
:github-wiki: https://github.com/{github-repo}/wiki
16-
:graphql-java-docs: https://www.graphql-java.com/documentation/v16
16+
:graphql-java-docs: https://www.graphql-java.com/documentation
1717
:javadoc: https://docs.spring.io/spring-graphql/docs/{spring-graphql-version}/api
1818
:spring-framework-ref-docs: https://docs.spring.io/spring-framework/docs/current/reference/html
1919

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

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ the following:
199199
- Expose {spring-boot-ref-docs}/application-properties.html#appendix.application-properties.web[properties]
200200
that apply to `GraphQlSource.Builder`.
201201
- 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].
202+
- Detect https://www.graphql-java.com/documentation/instrumentation[Instrumentation] beans for
203+
{spring-boot-ref-docs}/actuator.html#actuator.metrics.supported.spring-graphql[GraphQL metrics].
204204
- Detect `DataFetcherExceptionResolver` beans for
205205
<<execution-exceptions, exception resolution>>.
206206
- Detect `GraphQlSourceBuilderCustomizer` beans for any other customizations.
@@ -329,6 +329,40 @@ builder.schemaResources(..)
329329
----
330330

331331

332+
[[execution-graphqlsource-directives]]
333+
==== Directives
334+
335+
The GraphQL language supports directives that "describe alternate runtime execution and
336+
type validation behavior in a GraphQL document". Directives are similar to annotations in
337+
Java but declared on types, fields, fragments and operations in a GraphQL document.
338+
339+
GraphQL Java provides the `SchemaDirectiveWiring` contract to help applications detect
340+
and handle directives. For more details, see
341+
{graphql-java-docs}/sdl-directives/[Schema Directives] in the
342+
GraphQL Java documentation.
343+
344+
In Spring GraphQL you can register a `SchemaDirectiveWiring` through a
345+
<<execution-graphqlsource-runtimewiring-configurer>>. The Spring Boot starter detects
346+
such beans, so you might have something like:
347+
348+
[source,java,indent=0,subs="verbatim,quotes"]
349+
----
350+
@Configuration
351+
public class GraphQlConfig {
352+
353+
@Bean
354+
public RuntimeWiringConfigurer runtimeWiringConfigurer() {
355+
return builder -> builder.directiveWiring(new MySchemaDirectiveWiring());
356+
}
357+
358+
}
359+
----
360+
361+
TIP: For an example of directives support check out the
362+
https://github.com/graphql-java/graphql-java-extended-validation[Extended Validation for Graphql Java]
363+
library.
364+
365+
332366

333367
[[execution-reactive-datafetcher]]
334368
=== Reactive `DataFetcher`

0 commit comments

Comments
 (0)