diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/DefaultGraphQlSchemaCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/DefaultGraphQlSchemaCondition.java
index 77ead8392c0..a8f23e64415 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/DefaultGraphQlSchemaCondition.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/DefaultGraphQlSchemaCondition.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2023 the original author or authors.
+ * Copyright 2012-2025 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.
@@ -34,13 +34,15 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternUtils;
import org.springframework.core.type.AnnotatedTypeMetadata;
+import org.springframework.graphql.execution.GraphQlSource;
/**
* {@link Condition} that checks whether a GraphQL schema has been defined in the
* application. This is looking for:
*
* - schema files in the {@link GraphQlProperties configured locations}
- * - or infrastructure beans such as {@link GraphQlSourceBuilderCustomizer}
+ * - or {@link GraphQlSourceBuilderCustomizer} beans
+ * - or a {@link GraphQlSource} bean
*
*
* @author Brian Clozel
@@ -82,6 +84,14 @@ class DefaultGraphQlSchemaCondition extends SpringBootCondition implements Confi
else {
messages.add((message.didNotFind("GraphQlSourceBuilderCustomizer").atAll()));
}
+ String[] graphqlSourceBeans = beanFactory.getBeanNamesForType(GraphQlSource.class, false, false);
+ if (graphqlSourceBeans.length != 0) {
+ match = true;
+ messages.add(message.found("graphqlSource").items(Arrays.asList(graphqlSourceBeans)));
+ }
+ else {
+ messages.add((message.didNotFind("GraphQlSource").atAll()));
+ }
return new ConditionOutcome(match, ConditionMessage.of(messages));
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java
index ffe7c386f51..b6a99df2762 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java
@@ -124,10 +124,14 @@ class GraphQlAutoConfigurationTests {
}
@Test
- void shouldBackOffWithCustomGraphQlSource() {
+ void shouldUseCustomGraphQlSource() {
this.contextRunner.withUserConfiguration(CustomGraphQlSourceConfiguration.class).run((context) -> {
assertThat(context).getBeanNames(GraphQlSource.class).containsOnly("customGraphQlSource");
- assertThat(context).hasSingleBean(GraphQlProperties.class);
+ assertThat(context).hasSingleBean(GraphQlProperties.class)
+ .hasSingleBean(BatchLoaderRegistry.class)
+ .hasSingleBean(ExecutionGraphQlService.class)
+ .hasSingleBean(AnnotatedControllerConfigurer.class)
+ .hasSingleBean(EncodingCursorStrategy.class);
});
}