diff --git a/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQlAutoConfiguration.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQlAutoConfiguration.java index 778c10e4..628e90d3 100644 --- a/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQlAutoConfiguration.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQlAutoConfiguration.java @@ -65,7 +65,7 @@ public class GraphQlAutoConfiguration { .schemaResources(schemaResources.toArray(new Resource[0])) .exceptionResolvers(exceptionResolversProvider.orderedStream().collect(Collectors.toList())) .instrumentation(instrumentationsProvider.orderedStream().collect(Collectors.toList())); - wiringConfigurers.orderedStream().forEach(builder::runtimeWiringConfigurer); + wiringConfigurers.orderedStream().forEach(builder::configureRuntimeWiring); sourceCustomizers.orderedStream().forEach((customizer) -> customizer.customize(builder)); return builder.build(); } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/data/method/AnnotatedDataFetcherConfigurer.java b/spring-graphql/src/main/java/org/springframework/graphql/data/method/AnnotatedDataFetcherConfigurer.java index 88fa42e3..ea73bc43 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/data/method/AnnotatedDataFetcherConfigurer.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/data/method/AnnotatedDataFetcherConfigurer.java @@ -61,7 +61,7 @@ import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; /** - * A {@link RuntimeWiringConfigurer} that detects {@link SchemaMapping @SchemaMapping} + * {@link RuntimeWiringConfigurer} that detects {@link SchemaMapping @SchemaMapping} * annotated handler methods in {@link GraphQlController @GraphQlController} * classes and registers them as {@link DataFetcher}s. * @@ -181,8 +181,8 @@ public class AnnotatedDataFetcherConfigurer @Override public void configure(RuntimeWiring.Builder builder) { - Assert.state(this.argumentResolvers != null, "`argumentResolvers` not initialized"); - Assert.state(this.applicationContext != null, "ApplicationContext is required"); + Assert.notNull(this.applicationContext, "ApplicationContext is required"); + Assert.notNull(this.argumentResolvers, "`argumentResolvers` are required"); detectHandlerMethods().forEach((coordinates, handlerMethod) -> { DataFetcher dataFetcher = new AnnotatedDataFetcher(coordinates, handlerMethod, this.argumentResolvers); @@ -301,7 +301,6 @@ public class AnnotatedDataFetcherConfigurer if (hasTypeName && hasFieldName) { return coordinates; } - String typeName = coordinates.getTypeName(); if (!hasTypeName) { for (MethodParameter parameter : handlerMethod.getMethodParameters()) { @@ -315,7 +314,6 @@ public class AnnotatedDataFetcherConfigurer "No parentType specified, and a source/container method argument was also not found: " + handlerMethod.getShortLogMessage()); } - return FieldCoordinates.coordinates(typeName, (hasFieldName ? coordinates.getFieldName() : handlerMethod.getMethod().getName())); } @@ -333,7 +331,6 @@ public class AnnotatedDataFetcherConfigurer return entry.getKey() + " => " + method.getName() + methodParameters; }) .collect(Collectors.joining("\n\t", "\n\t" + formattedType + ":" + "\n\t", "")); - } } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultGraphQlSourceBuilder.java b/spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultGraphQlSourceBuilder.java index 6cbb2bcb..9129f4e3 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultGraphQlSourceBuilder.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultGraphQlSourceBuilder.java @@ -70,7 +70,7 @@ class DefaultGraphQlSourceBuilder implements GraphQlSource.Builder { } @Override - public GraphQlSource.Builder runtimeWiringConfigurer(RuntimeWiringConfigurer configurer) { + public GraphQlSource.Builder configureRuntimeWiring(RuntimeWiringConfigurer configurer) { this.runtimeWiringConfigurers.add(configurer); return this; } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/execution/ExecutionGraphQlService.java b/spring-graphql/src/main/java/org/springframework/graphql/execution/ExecutionGraphQlService.java index 9d5636dd..3a35c72b 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/execution/ExecutionGraphQlService.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/execution/ExecutionGraphQlService.java @@ -40,9 +40,11 @@ public class ExecutionGraphQlService implements GraphQlService { } @Override - public Mono execute(RequestInput input) { - ExecutionInput executionInput = input.toExecutionInput(); + public final Mono execute(RequestInput requestInput) { + ExecutionInput executionInput = requestInput.toExecutionInput(); + GraphQL graphQl = this.graphQlSource.graphQl(); + return Mono.deferContextual((contextView) -> { ReactorContextManager.setReactorContext(contextView, executionInput); return Mono.fromFuture(graphQl.executeAsync(executionInput)); diff --git a/spring-graphql/src/main/java/org/springframework/graphql/execution/GraphQlSource.java b/spring-graphql/src/main/java/org/springframework/graphql/execution/GraphQlSource.java index 2cda627a..7b996841 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/execution/GraphQlSource.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/execution/GraphQlSource.java @@ -86,7 +86,7 @@ public interface GraphQlSource { * @return the current builder * @see graphql.schema.idl.SchemaGenerator#makeExecutableSchema(TypeDefinitionRegistry, RuntimeWiring) */ - Builder runtimeWiringConfigurer(RuntimeWiringConfigurer configurer); + Builder configureRuntimeWiring(RuntimeWiringConfigurer configurer); /** * Add {@link DataFetcherExceptionResolver}'s to use for resolving exceptions from diff --git a/spring-graphql/src/test/java/org/springframework/graphql/GraphQlTestUtils.java b/spring-graphql/src/test/java/org/springframework/graphql/GraphQlTestUtils.java index bf3bf454..5c62d807 100644 --- a/spring-graphql/src/test/java/org/springframework/graphql/GraphQlTestUtils.java +++ b/spring-graphql/src/test/java/org/springframework/graphql/GraphQlTestUtils.java @@ -54,7 +54,7 @@ public abstract class GraphQlTestUtils { return GraphQlSource.builder() .schemaResources(new ByteArrayResource(schemaContent.getBytes(StandardCharsets.UTF_8))) - .runtimeWiringConfigurer(wiring -> wiring.type(typeName, (builder) -> builder.dataFetcher(fieldName, fetcher))); + .configureRuntimeWiring(wiring -> wiring.type(typeName, (builder) -> builder.dataFetcher(fieldName, fetcher))); } } diff --git a/spring-graphql/src/test/java/org/springframework/graphql/data/method/AnnotatedDataFetcherInvocationTests.java b/spring-graphql/src/test/java/org/springframework/graphql/data/method/AnnotatedDataFetcherInvocationTests.java index 40cf321b..f0479c98 100644 --- a/spring-graphql/src/test/java/org/springframework/graphql/data/method/AnnotatedDataFetcherInvocationTests.java +++ b/spring-graphql/src/test/java/org/springframework/graphql/data/method/AnnotatedDataFetcherInvocationTests.java @@ -187,7 +187,7 @@ public class AnnotatedDataFetcherInvocationTests { GraphQlSource graphQlSource = GraphQlSource.builder() .schemaResources(new ClassPathResource("books/schema.graphqls")) - .runtimeWiringConfigurer(configurer::configure) + .configureRuntimeWiring(configurer::configure) .build(); return graphQlSource.graphQl(); diff --git a/spring-graphql/src/test/java/org/springframework/graphql/data/querydsl/QuerydslDataFetcherTests.java b/spring-graphql/src/test/java/org/springframework/graphql/data/querydsl/QuerydslDataFetcherTests.java index 8f2c8e90..b20fd82f 100644 --- a/spring-graphql/src/test/java/org/springframework/graphql/data/querydsl/QuerydslDataFetcherTests.java +++ b/spring-graphql/src/test/java/org/springframework/graphql/data/querydsl/QuerydslDataFetcherTests.java @@ -282,7 +282,7 @@ class QuerydslDataFetcherTests { if (configurer != null) { TypeRuntimeWiring.Builder typeBuilder = TypeRuntimeWiring.newTypeWiring("Query"); configurer.accept(typeBuilder); - graphQlSourceBuilder.runtimeWiringConfigurer(wiring -> wiring.type(typeBuilder)); + graphQlSourceBuilder.configureRuntimeWiring(wiring -> wiring.type(typeBuilder)); } GraphQLTypeVisitor visitor = QuerydslDataFetcher.registrationTypeVisitor( diff --git a/spring-graphql/src/test/java/org/springframework/graphql/web/BookTestUtils.java b/spring-graphql/src/test/java/org/springframework/graphql/web/BookTestUtils.java index 9ff0b4b7..f803f91f 100644 --- a/spring-graphql/src/test/java/org/springframework/graphql/web/BookTestUtils.java +++ b/spring-graphql/src/test/java/org/springframework/graphql/web/BookTestUtils.java @@ -69,7 +69,7 @@ public abstract class BookTestUtils { private static GraphQlSource graphQlSource() { return GraphQlSource.builder() .schemaResources(new ClassPathResource("books/schema.graphqls")) - .runtimeWiringConfigurer(builder -> builder.type(TypeRuntimeWiring.newTypeWiring("Query") + .configureRuntimeWiring(builder -> builder.type(TypeRuntimeWiring.newTypeWiring("Query") .dataFetcher("bookById", (env) -> { Long id = Long.parseLong(env.getArgument("id")); return BookSource.getBook(id);