What are the differences between Apollo Client and Relay? [closed]

☆樱花仙子☆ 提交于 2019-12-06 07:10:49

问题


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.


回答1:


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 constrast 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.



来源:https://stackoverflow.com/questions/43233760/what-are-the-differences-between-apollo-client-and-relay

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!