Spring Startup: class java.lang.String cannot be cast to class graphql.schema.GraphQLDirective
See original GitHub issueWhat version are you using? com.expediagroup:graphql-kotlin-spring-server:5.4.1
A clear and concise description of what the bug is.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'routerFunctionMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfiguration$EnableWebFluxConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.expediagroup.graphql.server.spring.GraphQLRoutesConfiguration': Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'springGraphQLServer' defined in class path resource [com/expediagroup/graphql/server/spring/GraphQLSchemaConfiguration.class]: Unsatisfied dependency expressed through method 'springGraphQLServer' parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLRequestHandler' defined in class path resource [com/expediagroup/graphql/server/spring/GraphQLSchemaConfiguration.class]: Unsatisfied dependency expressed through method 'graphQLRequestHandler' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQL' defined in class path resource [com/expediagroup/graphql/server/spring/GraphQLSchemaConfiguration.class]: Unsatisfied dependency expressed through method 'graphQL' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'schema' defined in class path resource [com/expediagroup/graphql/server/spring/NonFederatedSchemaAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [graphql.schema.GraphQLSchema]: Factory method 'schema' threw exception; nested exception is java.lang.ClassCastException: class java.lang.String cannot be cast to class graphql.schema.GraphQLDirective (java.lang.String is in module java.base of loader 'bootstrap'; graphql.schema.GraphQLDirective is in unnamed module of loader 'app')
Steps to reproduce the behavior. Create a base Spring Application - https://start.spring.io/ Minimal Setup via Tutorial With One Query - https://opensource.expediagroup.com/graphql-kotlin/docs/
A clear and concise description of what you expected to happen. Spring Application successful run? What I’m doing wrong? 😃
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
Hello 👋 The underlying issue is that starting with Spring Boot 2.7.0 they (Spring Boot folks) started to manage
graphql-java
as one of their dependencies (which is used by the newly releasedspring-graphql
package). TLDR they depend ongraphql-java
v18.1 whereasgraphql-kotlin
5.x depends on v17.Solutions are either to
graphql-kotlin
5.x (or simply usegraphql-kotlin-spring-server
which pulls in the appropriate Spring Boot libs)graphql-kotlin
5.x but manually override thegraphql-java
version to v17graphql-kotlin
6.x (final release has pending federation v2 changes)https://github.com/ExpediaGroup/graphql-kotlin/releases/tag/5.5.0