Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should I use Apollo/Relay over urql? [closed]

Tags:

I'm working on the application that uses GraphQL. I'm using urql GraphQL client and really like it so far. What are the advantages of using Apollo/Relay over urlql?

like image 750
A. Karnaval Avatar asked Jul 17 '19 22:07

A. Karnaval


People also ask

Is Relay better than Apollo?

For example, both Apollo and Relay support normalized caching, while URQL supports document and normalized caching. The most fundamental difference between the three clients is in their core philosophy. Apollo is flexible and easygoing, Relay is opinionated and structured, and URQL is lightweight and extensible.

How does the Apollo cache work?

Apollo Client stores the results of your GraphQL queries in a local, normalized, in-memory cache. This enables Apollo Client to respond almost immediately to queries for already-cached data, without even sending a network request. The Apollo Client cache is highly configurable.

What is normalized cache?

Normalization refers to the practice of reducing redundancy. In databases, reducing redundancy means reducing the amount of duplicate data by adjusting the structure of your database. With Apollo, cache normalization means using cache to reduce the number of duplicate API requests.

What is Relay modern?

Relay Modern comes with automatic Flow type generation for the fragments used in Relay containers based on the GraphQL schema. Using these Flow types can help make an application less error-prone, by ensuring all possible null or undefined cases are considered even if they don't happen frequently.


1 Answers

Core contributor of urql here. Probably a late reply, but better than never

There are distinct advantages and disadvantages of using one of the three over the others.

Relay is strict in terms of what it requires from your schema, but that means that it has very easy-to-use patterns for the most common use cases. It'll help you to set up pagination with little extra code, but overall it does require you to add more boilerplate to an app that may otherwise be quite small.

Apollo is the most popular solution and a good "all arounder". It has some defaults, which sometimes may seem quirky, but aim to solve the 99% use-case—so to speak. It comes with a generic normalised cache built-in, which can be applied to any API, and allows you to specify exceptions to its normal caching logic (cache updates) with your mutations.

urql is the newest library and aims to be easy to use, small and customisable. It doesn't come with normalised caching out of the box, like Apollo or Relay does, but that can be added on separately. While the API is simple, it does allow for deep customisation, which is a double-edged sword: You can likely workaround unexpected problems and code solutions for your specific API, but it may require you to learn about urql's "Exchanges" later on.

There's also a longer section on "urql vs Relay vs Apollo" on the How to GraphQL site: https://www.howtographql.com/react-urql/0-introduction/

Hope this helps and isn't too biased!

like image 98
Phil Plückthun Avatar answered Nov 06 '22 11:11

Phil Plückthun