Fix build after Spring for GraphQL changes

See spring-projects/spring-graphql#244
This commit is contained in:
Brian Clozel
2022-01-14 21:05:15 +01:00
parent b67cc62c37
commit 68806bfef8
3 changed files with 18 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
package org.springframework.boot.autoconfigure.graphql.data;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -43,8 +42,9 @@ import org.springframework.graphql.execution.GraphQlSource;
* matching return type.
*
* @author Rossen Stoyanchev
* @author Brian Clozel
* @since 2.7.0
* @see QuerydslDataFetcher#autoRegistrationTypeVisitor(List, List)
* @see QuerydslDataFetcher#autoRegistrationConfigurer(List, List)
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ GraphQL.class, QuerydslDataFetcher.class, QuerydslPredicateExecutor.class })
@@ -59,11 +59,11 @@ public class GraphQlQuerydslAutoConfiguration {
return (builder) -> {
List<QuerydslPredicateExecutor<?>> executors = executorsProvider.stream().collect(Collectors.toList());
List<ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors = reactiveExecutorsProvider.stream()
.collect(Collectors.toList());
if (!executors.isEmpty()) {
builder.typeVisitors(Collections
.singletonList(QuerydslDataFetcher.autoRegistrationTypeVisitor(executors, reactiveExecutors)));
List<ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors = reactiveExecutorsProvider.stream()
.collect(Collectors.toList());
builder.configureRuntimeWiring(
QuerydslDataFetcher.autoRegistrationConfigurer(executors, reactiveExecutors));
}
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,8 +42,9 @@ import org.springframework.graphql.execution.GraphQlSource;
* matching return type.
*
* @author Rossen Stoyanchev
* @author Brian Clozel
* @since 2.7.0
* @see QuerydslDataFetcher#autoRegistrationTypeVisitor(List, List)
* @see QuerydslDataFetcher#autoRegistrationConfigurer(List, List)
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ GraphQL.class, QuerydslDataFetcher.class, ReactiveQuerydslPredicateExecutor.class })
@@ -59,8 +60,8 @@ public class GraphQlReactiveQuerydslAutoConfiguration {
List<ReactiveQuerydslPredicateExecutor<?>> executors = executorsProvider.stream()
.collect(Collectors.toList());
if (!executors.isEmpty()) {
builder.typeVisitors(Collections.singletonList(
QuerydslDataFetcher.autoRegistrationTypeVisitor(Collections.emptyList(), executors)));
builder.configureRuntimeWiring(
QuerydslDataFetcher.autoRegistrationConfigurer(Collections.emptyList(), executors));
}
};
}

View File

@@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.graphql;
import java.nio.charset.StandardCharsets;
import graphql.GraphQL;
import graphql.execution.instrumentation.ChainedInstrumentation;
import graphql.execution.instrumentation.Instrumentation;
@@ -30,6 +32,7 @@ import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.graphql.GraphQlService;
import org.springframework.graphql.data.method.annotation.support.AnnotatedControllerConfigurer;
@@ -182,7 +185,9 @@ class GraphQlAutoConfigurationTests {
@Bean
GraphQlSource customGraphQlSource() {
return mock(GraphQlSource.class);
ByteArrayResource schemaResource = new ByteArrayResource(
"type Query { greeting: String }".getBytes(StandardCharsets.UTF_8));
return GraphQlSource.builder().schemaResources(schemaResource).build();
}
}