GraphQl Java客户端的建议

发布于 2025-01-28 22:41:35 字数 570 浏览 3 评论 0 原文

我是GraphQL的新手,自最近几周以来一直在探索它。我正在寻找Java中GraphQL客户端的建议。

当我们在基于Java的应用程序上工作时,如果某人可以将我指向具有基本功能的不同graphql Java客户端,则非常感谢它具有 查询/突变/订阅。。

我探索了其中的一些,例如 dgs by netflix ,与 Spring Boot 的集成,并具有注释支持。但是,在得出结论之前,如果我能在以下方面进行不同的Java客户端的比较,我将非常感谢:

  1. 支持扩展Java标量类型等功能等
  2. 。广泛使用。
  3. 限制如果有的话。
  4. 简单而易于使用

如果可能的话,请为受欢迎的客户分享相应的链接。

感谢您的帮助!提前致谢。

I am new to GraphQL and was exploring it since last few weeks. I am looking for suggestions for GraphQL Clients in Java.

As we work on Java based application, would really appreciate if some-one can point me to the different GraphQL Java Clients which have the basic features like query/mutation/subscription.

I explored some of them like DGS framework by Netflix, which has integration with Spring Boot and has annotation support. However before arriving to conclusion, would really appreciate if i can get a comparison of different Java Clients on the following aspects:

  1. Set of features like support for extended java scalars types etc.
  2. The ones which are in active development as well as the ones which are used extensively.
  3. Limitations if any.
  4. Simple and easy to use
  5. OpenSource?

If at all possible, please do share the respective links for the popular clients.

Appreciate your Help!! Thanks in Advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

腻橙味 2025-02-04 22:41:35

编辑:此答案重点介绍了您提到的Spring-boot时的GraphQl Java服务器。如果您追求GraphQl Java客户端,我建议您推荐 apollo client ,它易于使用

免责声明:我从未使用过DGS,并且在过去的一年中,我从未积极使用GraphQl-Java,情况可能发生了变化。我尝试了GraphQl-Java-Tools和SPQR。 的。

这个答案是有意义 它是开源的,您会发现许多项目已建立在其上。可以在 graphl-java reporsitories 的项目中,可以在GraphQl-Java本身中添加功能,使GraphQl-Java非常模块化,并且适应您的需求。

例如:

graphql-java非常详细,我不建议按原样使用它。相反,我建议使用以下项目之一。

https://github.com/kobylynskyi/graphql-java-java-codegen 生成您的图形从您的架构中的服务器/客户端,按照模式进行第一次方法

https://github.com/github.com/github.com/leangen/leangen/graphql--graphql------ spqr https://github.com/github.com/graphql-java-antis/graphql-java-annotations < /a>遵循代码的第一种方法,并非常有效地利用注释来从您的代码中生成模式(SPQR还提供了弹簧启动器)

https://github.com/graphql-java-kickstart/graphql-java-tools DTO。它需要大多数锅炉板代码。这是弹簧友好的(如果用于弹簧框架,则GraphQl-Java-Tools解析器将非常直观),并且具有弹簧靴的启动。模式解析器和类发现是强大但模块化的。

功能

在功能方面,所有这些项目都利用GraphQl-Java的功能,它们将非常相似。

主动开发和社区采用

GraphQl-Java-Tools昨天进行了更新,SPQR和GraphQl-Java-Antodations,去年,一月份的GraphQl-Java-Codegen。从阅读stackoverflow问题,GraphQl-Java-Tools和SPQR似乎是最受欢迎的 - 但我可能错了。

限制

我无法想到。

易用性

spqr赢得了我的胜利,注释确实是直观的,会让您快速发展。还有一个弹簧启动器和一些示例项目。
GraphQl-Java-Tools更为复杂,但它们具有良好的文档和示例项目。
我会为较小的/新项目和GraphQl-Java-Tools推荐SPQR,用于较大的项目或现有项目,这些项目需要在现有代码库中构建GraphQL-API。对于我的个人项目,我搬到了SPQR,从不后悔。

开源

此答案中引用的所有项目都是开源的。

最后一个词:

我认为代码优先的方法(在Java中定义您的API,让库生成您的模式)或模式 - 优先方法(在模式文件中定义您的API,让库生成您的API代码)可能是决定要使用哪个库的最重要因素。您可以阅读 SPQR作者)出色的答案了解更多。

EDIT: this answer focuses on graphql java servers as you mentioned spring-boot. If you are after graphql java clients, I would recommend the Apollo Client, it is easy to use and does everything you could need.

Disclaimer: I have never used DGS, and I have not been using graphql-java actively in the last year, things might have changed. I have tried graphql-java-tools and spqr. This answer is opinionated.

The graphql implementation graphql-java was around before DGS. It is open source and you will find many project have been built on top of it. Projects that add features to graphql-java itself can be found in the graphl-java repositories, making graphql-java quite modular and adaptable to your needs.

For example:

Graphql-java is quite verbose, and I would not recommend using it as is. Instead I would recommend using one of the following projects.

https://github.com/kobylynskyi/graphql-java-codegen generate your graphql server/client from your schema, following a schema first approach

https://github.com/leangen/graphql-spqr or https://github.com/Enigmatis/graphql-java-annotations follow a code first approach and makes a very efficient use of annotation to generate your schema from your code (spqr also provide a spring-boot starter)

https://github.com/graphql-java-kickstart/graphql-java-tools use a schema first approach and that let you create your own DTO. It takes care of most of the boiler plate code. It is Spring friendly (if used to the Spring framework, the graphql-java-tools resolver will be very intuitive), and has a spring-boot start. The schema parser and class discovery are powerful yet modular.

Features

In term of features, all those projects leverage the feature of graphql-java, they will be very similar.

Active development and community adoption

graphql-java-tools was updated yesterday, spqr and graphql-java-annotations last year, graphql-java-codegen in January. From reading stackoverflow questions, graphql-java-tools and spqr seem to be the most popular - but I could be wrong.

Limitations

None that I can think of.

Ease of use

SPQR wins that one for me, the annotations are really intuitive and will get you going super quickly. There is also a spring-boot-starter and a few sample projects.
graphql-java-tools is a bit more complex but they have a good documentation and sample projects.
I would recommend SPQR for smaller/new projects and graphql-java-tools for bigger projects or existing projects that needs to build a graphql-api on top of an existing code base. For my personal projects, I moved to SPQR and never regretted it.

Open Source

All the projects referenced in this answer are open source.

Final word:

I think the code-first approach (define your api in java, let the library generate your schema) or schema-first approach (define your api in a schema file, let the library generate your code) is probably the most important factor in deciding which library to go for. You can read my answer and Kaqqao's (SPQR author) excellent answer to learn more.

甜宝宝 2025-02-04 22:41:35

如果您遵循架构 - 首选方法并想生成客户端类,我建议使用

是如何使用生成类构建请求的一些示例

If you are following schema-first approach and would like to generate client-side classes, I recommend using https://github.com/kobylynskyi/graphql-java-codegen.

Here are a few examples of how you can use generated classes to build requests and call GraphQL API from Java:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文