Which graphql-spring-boot-starter should I choose?
Asked Answered
S

1

6

I'm thinking about adding GraphQL functionalities to my Spring Boot application.

I found there are two artifacts for that.

One is com.graphql-java-kickstart:graphql-spring-boot-starter and the other is com.graphql-java:graphql-spring-boot-starter.

Which one should I choose?

Schwerin answered 18/1, 2019 at 9:45 Comment(0)
V
8

These are different Starters (by different teams) providing different features, so there's no right or wrong answer. Here's a quick overview of what I'm aware is available:

The original starter made by the graphql-java team (com.graphql-java:graphql-spring-boot-starter) is now, I believe, defunct and superseded by the Spring GraphQL.

Spring GraphQL (org.springframework.boot:spring-boot-starter-web or org.springframework.boot:spring-boot-starter-webflux) is intended for schema-first development, is easy to use and works well with other Spring projects (like e.g. WebFlux and Spring Security).

DGS by Netflix (com.netflix.graphql.dgs:graphql-dgs-spring-boot-starter) has also been folded into Spring GraphQL.

If you want to go code-first (which I argue is still schema-first, just better), use graphql-spqr-spring-boot-starter, which will generate the GraphQL schema and an end-point for you, with no extra code needed. It's the quickest way possible to expose Spring services. There's a sample project here. I'm the main author of that project, so this is a shameless plug, but I honestly believe it's lightyears ahead of other projects in terms of usability. The next version will be based on Spring GraphQL, so it should inherit most/all benefits as well (like e.g. RSocket support, which it currently lacks).

If you're already using graphql-java-tools (maintained by the Kickstart team), you'll likely want to go for com.graphql-java-kickstart:graphql-spring-boot-starter as they're intended to be used together. I have no clue how actively this project is maintained these days.

Velar answered 12/2, 2019 at 23:26 Comment(4)
I've used your project before and found it quite easy to use. I wasn't aware of the other projects. I will likely check them out for self-edification. Thanks.Harden
Also should mention that Netflix offers the DGS framework, which is an abstraction built on top of graphql-java. It was built specifically to be incorporated into Spring :) netflix.github.io/dgsKowal
Great library. Really waiting for Spring Boot 3 support. Also proposing out-of-the-box support for protobuf classes. That will be somethingBurdelle
@LewisMunene Upgrading to Spring Boot3 is actually trivial, but I'm trying to rebase the starter onto Spring GraphQL, to avoid maintaining the features already implemented there. As for Protobuf, I've never used it... would you be interested in contributing a module?Velar

© 2022 - 2024 — McMap. All rights reserved.