Document classpath* location for looking up GraphQL schemas across modules
See original GitHub issueVersion Spring Boot 2.7.1
Description
We created a new itest source set in Gradle and when we run the test using @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT), seems like the autoconfigure GraphQL components are not provisioned.
How to reproduce it This project contains a pretty simple GraphQL controller, with two tests:
- One inside the
testsource set, using RestAssured to call the GraphQL endpoint, which works fine (HTTP 200) - One inside the
itestsource set, using RestAssured to call the GraphQL endpoint, which doesn’t work (HTTP 404)
Clues
I did some debugging and found that ConditionalOnGraphQlSchema returns true for the test source set, and false for the itest source set, it seems like this line on DefaultGraphQlSchemaCondition cannot find the GraphQL schema, and therefore, Spring Boot doesn’t contribute the Graphql autoconfiguration.
My guess is this issue might be for Spring Boot and not Gradle configuration, as other resources work fine, like liquibase changelogs and application.yml files.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)

Top Related StackOverflow Question
Thanks Rossen, I’ll add a similar note in the Spring Boot reference docs, I’ll turn this into a documentation issue then.
As of https://github.com/spring-projects/spring-graphql/issues/338, we look in different places for schema vs test request vs client request files, which eliminates a very basic reason to shadowing
graphql/under main and test sources that most apps would run into otherwise.For the rest, using
classpath*:by default will find all possible candidates out of the box, including some that may not be intended for inclusion, whileclasspath:requires an explicit action to decide how to deal with such shadowing. I tend to think the more explicit opt-in option is preferable. I’ve already made an adjustment to the Spring for GraphQL docs to make that easier to spot.