Hacker News new | ask | show | jobs
by mjmahone17 3346 days ago
From what I know of Apollo (which is a lot less than Relay, having worked on the RelayModern compiler), this comparison is pretty good.

(1) is true, for the most part, from the developer point of view. But when you're using the compatibility mode of RelayModern (i.e. sending out a legacy query that contains modern fragments), Relay does runtime query building from the Modern fragments.

(2) Relay allows you to define updaters for mutations, which lets you write client-defined data transformations. This may not be as complex as what's happening in the Apollo client, but I don't have the experience to say. See http://facebook.github.io/relay/docs/mutations.html#updating...

Edit: I'm Matt, and I work on a sibling team to Relay at Facebook, and helped build RelayModern's compiler.

1 comments

Agree that this is overall accurate, especially wrt to Relay Classic. For Relay Modern, however:

> 2. Relay doesn't have as many facilities for updating the store and working with mutation results.

Apollo and Relay Modern are about equal in this regard. Relay supports arbitrary writes to the store (either via an imperative API, via a fragment + payload, or a mix of the two), plus similar APIs for updating the store after a mutation or subscription update. This includes the ability to update client-only state.

> 3. The Apollo Store is a plain JavaScript object,

The Relay Modern store is also a plain object. There aren't currently any convenience functions for serializing/deserializing it, but this is something we're open to adding.

Overall I'd say the main differences is that Apollo has focused very much on easier onboarding and covering a wide variety of use cases (many view layer integrations, developer tooling etc), where Relay is more focused on performance and scalability (hence features such as ahead-of-time optimization, garbage collection, etc).

Either are appropriate depending on your specific needs. I'm excited to see so much iteration in this space!