Replies: 1 comment 1 reply
|
This is a classic Spring GraphQL + codegen + external schema JAR issue. Your setup is almost correct — the problem is not Gradle, not the JAR, and not codegen itself. The root cause is:
What’s actually going wrongYour flow is:
At runtime, Spring GraphQL builds the schema and sees: But Spring GraphQL asks:
And the answer is: nowhere in the Spring context. Even though:
➡️ Spring GraphQL does NOT scan dependencies for scalars automatically Key rule (important)
External JAR ≠ auto-registered scalar. The fix (correct & recommended)1️⃣ Expose the scalar as a Spring beanIn
That is not enough. You must expose it as a Spring bean from the application that runs. 2️⃣ Register the scalar in |
| Problem | Cause | Fix |
|---|---|---|
| There is no scalar implementation for 'Year' | Scalar exists but is not a Spring bean | Register GraphQLScalarType as a bean in hello-app |
| External JAR scalar not detected | Spring GraphQL does not auto-scan dependencies | Explicit bean registration |
| Codegen works but runtime fails | Codegen ≠ runtime wiring | Runtime wiring needs Spring context |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello, I have 2 gradle projects:
hello-graphqldefining all the graphQL schemas,hello-app, the spring boot application usinghello-graphqlhello-graphqldefines a custom scalaryear. It is used in the Person graphQL definition.Issue
I am facing issues when I want to use this library in my spring boot application:
It seems that Spring boot is not able to detect the
Yearscalar.I use codegen since my graphQL definitions are in a external JAR.
To reproduce
git clone https://github.com/Mcdostone/hello-graphql cd hello-graphql ./gradlew clean build ./gradlew :hello-app:bootRunThanks for your help
All reactions