我应该选择哪个 graphql-spring-boot-starter?

Which graphql-spring-boot-starter should I choose?

我正在考虑将 GraphQL 功能添加到我的 Spring 引导应用程序中。

我发现有两个工件。

一个是com.graphql-java-kickstart:graphql-spring-boot-starter,另一个是com.graphql-java:graphql-spring-boot-starter

我应该选择哪一个?

这些是不同的 Starters(来自不同的团队)提供不同的功能,因此没有正确或错误的答案。这是我知道可用的快速概述:

如果您正在使用纯 graphql-java(或者尚未使用任何东西并希望以模式优先的方式进行开发),您可能应该选择 com.graphql-java:graphql-spring-boot-starter.

Spring 本身有一个实验性的(到目前为止还很简单)启动器(org.springframework.boot:spring-boot-starter-weborg.springframework.boot:spring-boot-starter-webflux),它似乎是基本 graphql 的继承者- java首发。

如果你想代码优先(我认为是 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 quickest way possible to expose Spring services. There's a sample project here。我是那个项目的主要作者,所以这是一个无耻的插件,但我真的相信它比其他插件领先光年可用性方面的项目。

还有 Netflix 的 DGS (com.netflix.graphql.dgs:graphql-dgs-spring-boot-starter)。它也是模式优先的,但比使用纯 graphql-java(或 Spring,因为现在)。我对它没有第一手经验,但它有很好的文档记录,所以你应该可以毫无问题地找到你需要的东西。

如果您已经在使用 graphql-java-tools,您可能会想要使用 com.graphql-java-kickstart:graphql-spring-boot-starter,因为它们旨在一起使用。