From afb0b64d3a58d76291515462d44b2f0e48003762 Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Thu, 17 Feb 2022 15:17:27 +0000 Subject: [PATCH] Add section on directives in reference docs Closes gh-262 --- .../src/docs/asciidoc/attributes.adoc | 2 +- .../src/docs/asciidoc/index.adoc | 38 ++++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/spring-graphql-docs/src/docs/asciidoc/attributes.adoc b/spring-graphql-docs/src/docs/asciidoc/attributes.adoc index c27d5c5d..d8f2f635 100644 --- a/spring-graphql-docs/src/docs/asciidoc/attributes.adoc +++ b/spring-graphql-docs/src/docs/asciidoc/attributes.adoc @@ -13,7 +13,7 @@ :github-issues: https://github.com/{github-repo}/issues/ :github-main-branch: https://github.com/{github-repo}/tree/main :github-wiki: https://github.com/{github-repo}/wiki -:graphql-java-docs: https://www.graphql-java.com/documentation/v16 +:graphql-java-docs: https://www.graphql-java.com/documentation :javadoc: https://docs.spring.io/spring-graphql/docs/{spring-graphql-version}/api :spring-framework-ref-docs: https://docs.spring.io/spring-framework/docs/current/reference/html diff --git a/spring-graphql-docs/src/docs/asciidoc/index.adoc b/spring-graphql-docs/src/docs/asciidoc/index.adoc index a617b180..b059ef7a 100644 --- a/spring-graphql-docs/src/docs/asciidoc/index.adoc +++ b/spring-graphql-docs/src/docs/asciidoc/index.adoc @@ -199,8 +199,8 @@ the following: - Expose {spring-boot-ref-docs}/application-properties.html#appendix.application-properties.web[properties] that apply to `GraphQlSource.Builder`. - Detect <> beans. -- Detect `Instrumentation` beans for GraphQL - {spring-boot-ref-docs}/actuator.html#actuator.metrics.supported.spring-graphql[metrics]. +- Detect https://www.graphql-java.com/documentation/instrumentation[Instrumentation] beans for + {spring-boot-ref-docs}/actuator.html#actuator.metrics.supported.spring-graphql[GraphQL metrics]. - Detect `DataFetcherExceptionResolver` beans for <>. - Detect `GraphQlSourceBuilderCustomizer` beans for any other customizations. @@ -329,6 +329,40 @@ builder.schemaResources(..) ---- +[[execution-graphqlsource-directives]] +==== Directives + +The GraphQL language supports directives that "describe alternate runtime execution and +type validation behavior in a GraphQL document". Directives are similar to annotations in +Java but declared on types, fields, fragments and operations in a GraphQL document. + +GraphQL Java provides the `SchemaDirectiveWiring` contract to help applications detect +and handle directives. For more details, see +{graphql-java-docs}/sdl-directives/[Schema Directives] in the +GraphQL Java documentation. + +In Spring GraphQL you can register a `SchemaDirectiveWiring` through a +<>. The Spring Boot starter detects +such beans, so you might have something like: + +[source,java,indent=0,subs="verbatim,quotes"] +---- +@Configuration +public class GraphQlConfig { + + @Bean + public RuntimeWiringConfigurer runtimeWiringConfigurer() { + return builder -> builder.directiveWiring(new MySchemaDirectiveWiring()); + } + +} +---- + +TIP: For an example of directives support check out the +https://github.com/graphql-java/graphql-java-extended-validation[Extended Validation for Graphql Java] +library. + + [[execution-reactive-datafetcher]] === Reactive `DataFetcher`