Springboot 3 and GraphQL compatibility

3.3k Views Asked by At

I am upgrading my spring boot application from 2.1.6.RELEASE to 3.0.0 After resolving all the errors, the graphql apis are returning null and even the breakpoints are not getting triggered in any of the classes.

Does Spring boot 3 have support for GraphQL?

The following post kind of indicates that the support is not available but need some confirmation. https://spring.io/blog/2022/11/22/spring-for-graphql-1-0-3-released

3

There are 3 best solutions below

2
On BEST ANSWER
Upgrade to Spring Boot 3 and Java 17

Migrated to spring boot version 3.0.0 from 2.1.6.RELEASE
Migrated to Java 17 from Java 8
Removed GraphQLQueryResolver and GraphQLMutationResolver -  as they were not working
Used the following instead:
    Added @QueryMapping and @MutationMapping
    Changed Query and Mutation classes from @Component to @Controller
    Added jakarta.persistence-api dependency
    @Argument keyword added to the parameters in functions

Used the following dependency
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-graphql</artifactId>
        </dependency>
0
On

Use Spring boot 3.0.1. It's fixed in 3.0.1 version

0
On

As of Spring Boot 2.7.x, the Spring team released the new Spring GraphQL project. This is also currently supported with Spring Boot 3.0.

If you were using GraphQL support with Spring Boot 2.1.x, this means that your application is using a different project for GraphQL support. Could you share the name of the dependency you're using? Maybe this project is not yet compatible with Spring Boot 3.0?