问题描述
我刚刚被介绍给GraphQl,并在两个框架之间做出决定( apollo 和 relay )用于实现我的前端React Web应用程序.
我知道中继是由Facebook构建的,而Apollo是流星.有没有人尝试过,您的经验如何?我想知道它们之间有什么区别以及与Apollo相比,使用继电器更受益的GraphQl应用程序.
.推荐答案
tl; dr:这个问题的答案归结为"取决于".我鼓励您同时尝试GraphQL客户端,并得出自己的结论. 学习apollo 和学习中继是开始的绝佳资源.
请注意,以下是关于中继1,而不是中继2.
框架
中继仅在Apollo框架不可知的情况下使用React和RN.当您想构建一个React应用程序时,这对您来说不是一个问题,但仍然值得一提.
GraphQl API
继电器需要在 relay规范中进一步描述一个自定义模式. . Apollo与任何GraphQl架构一起使用.
灵活性
继电器强加了一个严格的固定结构,您绝对需要遵循.另一方面,阿波罗为您提供了许多不同的方法和选择特定主题的方法.
生产力
接力赛提供出色的开发人员体验,但具有很高的进入障碍.阿波罗需要更多的手动工作来完成工作.
难度
继电器引入了许多新概念,例如节点,边缘和连接,并重申,带有很高的入口屏障.与此相比,阿波罗非常容易开始.
订阅
除了一些社区努力使订阅与继电器一起工作外,对继电器中的订阅并没有达成共识.另一方面,Apollo与 subscriptions-transport-ws 社区.这是一个使用GraphQL订阅worldChat应用程序例如.
.模式检查
继电器需要使用babel在构建时间上使用babel进行架构检查.阿波罗为此提供了可选的工具.
问题描述
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.
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: 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.
Note that the following speaks about Relay 1, not Relay 2.
Frameworks
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.
GraphQL API
Relay requires a custom schema further described in the Relay specification. Apollo works with any GraphQL schema.
Flexibility
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.
Productivity
Relay offers great developer experience but comes with a high entry barrier. Apollo requires more manual work to get things done.
Difficulty
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.
Subscriptions
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.
Schema Check
Relay requires a schema check using Babel on build-time. Apollo offers optional tools for this instead.