Adapt to latest Spring for GraphQL changes

This commit adapts to changes done in spring-projects/spring-graphql#312
This commit is contained in:
Brian Clozel 2022-04-19 16:58:06 +02:00
parent ec31cb2303
commit d137f92f66
5 changed files with 17 additions and 14 deletions

View File

@ -80,8 +80,9 @@ public class GraphQlAutoConfiguration {
String[] schemaLocations = properties.getSchema().getLocations(); String[] schemaLocations = properties.getSchema().getLocations();
Resource[] schemaResources = resolveSchemaResources(resourcePatternResolver, schemaLocations, Resource[] schemaResources = resolveSchemaResources(resourcePatternResolver, schemaLocations,
properties.getSchema().getFileExtensions()); properties.getSchema().getFileExtensions());
GraphQlSource.Builder builder = GraphQlSource.builder().schemaResources(schemaResources) GraphQlSource.SchemaResourceBuilder builder = GraphQlSource.schemaResourceBuilder()
.exceptionResolvers(toList(exceptionResolvers)).instrumentation(toList(instrumentations)); .schemaResources(schemaResources).exceptionResolvers(toList(exceptionResolvers))
.instrumentation(toList(instrumentations));
if (!properties.getSchema().getIntrospection().isEnabled()) { if (!properties.getSchema().getIntrospection().isEnabled()) {
builder.configureRuntimeWiring(this::enableIntrospection); builder.configureRuntimeWiring(this::enableIntrospection);
} }

View File

@ -20,8 +20,8 @@ import org.springframework.graphql.execution.GraphQlSource;
/** /**
* Callback interface that can be implemented by beans wishing to customize properties of * Callback interface that can be implemented by beans wishing to customize properties of
* {@link org.springframework.graphql.execution.GraphQlSource.Builder Builder} whilst * {@link org.springframework.graphql.execution.GraphQlSource.SchemaResourceBuilder
* retaining default auto-configuration. * Builder} whilst retaining default auto-configuration.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 2.7.0 * @since 2.7.0
@ -30,10 +30,11 @@ import org.springframework.graphql.execution.GraphQlSource;
public interface GraphQlSourceBuilderCustomizer { public interface GraphQlSourceBuilderCustomizer {
/** /**
* Customize the {@link org.springframework.graphql.execution.GraphQlSource.Builder * Customize the
* {@link org.springframework.graphql.execution.GraphQlSource.SchemaResourceBuilder
* Builder} instance. * Builder} instance.
* @param builder builder the builder to customize * @param builder builder the builder to customize
*/ */
void customize(GraphQlSource.Builder builder); void customize(GraphQlSource.SchemaResourceBuilder builder);
} }

View File

@ -23,7 +23,7 @@ import java.util.stream.Collectors;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.graphql.GraphQlSourceBuilderCustomizer; import org.springframework.boot.autoconfigure.graphql.GraphQlSourceBuilderCustomizer;
import org.springframework.graphql.execution.GraphQlSource.Builder; import org.springframework.graphql.execution.GraphQlSource;
import org.springframework.graphql.execution.RuntimeWiringConfigurer; import org.springframework.graphql.execution.RuntimeWiringConfigurer;
/** /**
@ -59,7 +59,7 @@ class GraphQlQuerydslSourceBuilderCustomizer<E, R> implements GraphQlSourceBuild
} }
@Override @Override
public void customize(Builder builder) { public void customize(GraphQlSource.SchemaResourceBuilder builder) {
if (!this.executors.isEmpty() || !this.reactiveExecutors.isEmpty()) { if (!this.executors.isEmpty() || !this.reactiveExecutors.isEmpty()) {
builder.configureRuntimeWiring(this.wiringConfigurerFactory.apply(this.executors, this.reactiveExecutors)); builder.configureRuntimeWiring(this.wiringConfigurerFactory.apply(this.executors, this.reactiveExecutors));
} }

View File

@ -186,8 +186,9 @@ class GraphQlAutoConfigurationTests {
static class CustomGraphQlBuilderConfiguration { static class CustomGraphQlBuilderConfiguration {
@Bean @Bean
GraphQlSource.Builder customGraphQlSourceBuilder() { GraphQlSource.SchemaResourceBuilder customGraphQlSourceBuilder() {
return GraphQlSource.builder().schemaResources(new ClassPathResource("graphql/schema.graphqls"), return GraphQlSource.schemaResourceBuilder().schemaResources(
new ClassPathResource("graphql/schema.graphqls"),
new ClassPathResource("graphql/types/book.graphqls")); new ClassPathResource("graphql/types/book.graphqls"));
} }
@ -200,7 +201,7 @@ class GraphQlAutoConfigurationTests {
GraphQlSource customGraphQlSource() { GraphQlSource customGraphQlSource() {
ByteArrayResource schemaResource = new ByteArrayResource( ByteArrayResource schemaResource = new ByteArrayResource(
"type Query { greeting: String }".getBytes(StandardCharsets.UTF_8)); "type Query { greeting: String }".getBytes(StandardCharsets.UTF_8));
return GraphQlSource.builder().schemaResources(schemaResource).build(); return GraphQlSource.schemaResourceBuilder().schemaResources(schemaResource).build();
} }
} }
@ -258,7 +259,7 @@ class GraphQlAutoConfigurationTests {
public boolean applied = false; public boolean applied = false;
@Override @Override
public void customize(GraphQlSource.Builder builder) { public void customize(GraphQlSource.SchemaResourceBuilder builder) {
this.applied = true; this.applied = true;
} }

View File

@ -45,7 +45,7 @@ import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; import org.springframework.core.type.classreading.SimpleMetadataReaderFactory;
import org.springframework.graphql.execution.DataFetcherExceptionResolver; import org.springframework.graphql.execution.DataFetcherExceptionResolver;
import org.springframework.graphql.execution.GraphQlSource.Builder; import org.springframework.graphql.execution.GraphQlSource;
import org.springframework.graphql.execution.RuntimeWiringConfigurer; import org.springframework.graphql.execution.RuntimeWiringConfigurer;
import org.springframework.graphql.server.WebGraphQlInterceptor; import org.springframework.graphql.server.WebGraphQlInterceptor;
import org.springframework.graphql.server.WebGraphQlRequest; import org.springframework.graphql.server.WebGraphQlRequest;
@ -267,7 +267,7 @@ class GraphQlTypeExcludeFilterTests {
static class ExampleGraphQlSourceBuilderCustomizer implements GraphQlSourceBuilderCustomizer { static class ExampleGraphQlSourceBuilderCustomizer implements GraphQlSourceBuilderCustomizer {
@Override @Override
public void customize(Builder builder) { public void customize(GraphQlSource.SchemaResourceBuilder builder) {
} }