本文介绍了Apollo Client和Relay之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚被介绍给GraphQL,并且正在两个框架之间进行决策( Apollo 中继),以实现我的前端React Web应用.

I have just been introduced to GraphQL and am deciding between the two frameworks (Apollo and Relay) for implementing my front end React web app.

我知道Relay是由Facebook构建的,而Apollo是由Meteor构建的.有没有人尝试过这两种方法,您的经历如何?我想知道它们之间有什么区别,与使用Apollo相比,使用Relay可以使哪种GraphQL应用程序受益更多.

I'm aware that Relay is built by Facebook, while Apollo is by Meteor. Has anyone tried both and how has your experience been? I'm wondering what are the differences between them and which kind of GraphQL apps would benefit more from using Relay as compared to Apollo.

推荐答案

TL; DR:该问题的答案归结为取决于".我鼓励您尝试使用这两个GraphQL客户端,并得出自己的结论. 了解阿波罗学习中继是入门的好资源.

TL;DR: The answer to this question boils down to "it depends". I encourage you to try both GraphQL clients and come up with your own conclusion. Learn Apollo and Learn Relay are great resources to get started with this.

请注意,以下内容是关于中继1而非中继2的.

Note that the following speaks about Relay 1, not Relay 2.

当Apollo与框架无关时,中继仅适用于React和RN.当您要构建React应用时,这对您来说不是问题,但仍然值得一提.

Relay only works on React and RN while Apollo is framework agnostic. As you want to build a React app, that's not an issue for you, but it's still worth mentioning.

中继需要一个自定义模式,该模式将在中继规范中进一步描述. Apollo可与任何GraphQL模式一起使用.

Relay requires a custom schema further described in the Relay specification. Apollo works with any GraphQL schema.

中继施加了一个严格固定的结构,您绝对需要遵循该结构.另一方面,阿波罗(Apollo)为您提供了处理特定主题的许多不同方法和选择.

Relay imposes a strict, fixed structure that you absolutely need to follow. Apollo on the other hand gives you a lot of different approaches and choices for handling a particular topic.

Relay提供了出色的开发人员经验,但入门门槛很高.阿波罗需要更多的人工工作才能完成工作.

Relay offers great developer experience but comes with a high entry barrier. Apollo requires more manual work to get things done.

中继引入了许多新概念,例如节点,边和连接,并且重申一下,引入了很高的障碍.与此相反,Apollo非常容易上手.

Relay introduces a lot of new concepts like nodes, edges, and connections, and to reiterate, comes with a high entry barrier. Apollo is extremely easy to get started with in contrast to that.

除了一些社区努力使Relay能够使用订阅外,关于Relay的订阅还没有真正达成共识.另一方面,Apollo与 subscriptions-transport-ws 很好地集成在一起,该方法已经在社区.例如,这是一个使用GraphQL订阅的 worldchat应用.

Aside from some community efforts to make subscriptions work with Relay, there's not really a consensus about subscriptions in Relay. On the other hand, Apollo integrates nicely with subscriptions-transport-ws that already finds great adoption in the community. Here's a worldchat app using GraphQL subscriptions for example.

中继需要在构建时使用Babel进行模式检查.为此,Apollo提供了可选工具.

Relay requires a schema check using Babel on build-time. Apollo offers optional tools for this instead.

这篇关于Apollo Client和Relay之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 13:43