Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GraphQLSchema bean not created - Spring Boot

I am following this example here:- http://www.baeldung.com/spring-graphql

for me the GraphQLSchema bean is not getting autoregistered. it throws me this error:- No qualifying bean of type 'graphql.schema.GraphQLSchema' available

my Pom file has all requried Spring boot dependecies:-

graphql-spring-boot-starter
graphql-java-tools
graphiql-spring-boot-starter

I have following settings in application.proerties:-

graphql.root=/v1
graphql.servlet.mapping=${graphql.root}/graphql
graphql.servlet.enabled=true
graphql.servlet.corsEnabled=true

Not sure what am I missing, Do I need to explicitly define this bean as on this page:- https://github.com/graphql-java/graphql-spring-boot/blob/master/example/src/main/java/com/embedler/moon/graphql/boot/sample/ApplicationBootConfiguration.java.

But I thought it will autocreate for me, I just need to have *.graphqls on my class path.

like image 768
Atul Ojha Avatar asked Aug 08 '26 14:08

Atul Ojha


1 Answers

I have followed the same tutorial as well and encountered the same error. I ended up figuring out what the issue was and it is that you need to add @Component to the Query class that the tutorial describes.

Once that was done graphiql was finally finding the schema and the /graphql end-point was exposed.

like image 173
george_h Avatar answered Aug 11 '26 14:08

george_h



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!