News for hackers. Stuff that matters.
Re:GraphQL Is a Trap? by tracyhenry on Friday May 06, 2022 @12:31PM (#31287095)
Checkout Relay.js: https://relay.dev/

It does a lot of client-side caching for you. The documentation is atrocious though IMO. I'm not sure if there exists a similar framework for backend caching.

Re:GraphQL Is a Trap? by arinlen on Friday May 06, 2022 @01:44PM (#31287916)
> Checkout Relay.js: https://relay.dev/

Relay is a GraphQL client. That's the irrelevant side of caching, because that can be trivially implemented by an intern, specially given GraphQL's official copout of caching based on primary keys [1], and doesn't have any meaningful impact on the client's resources.

The relevant side of caching is server-side caching: the bits of your system that allow it to fulfill results while skipping the expensive bits, like having to hit the database. This is what really matters both in terms of operational costs and performance, and this is what GraphQL fails to deliver.

[1] https://graphql.org/learn/caching/

Re:GraphQL Is a Trap? by tracyhenry on Friday May 06, 2022 @02:00PM (#31288083)
https://relay.dev/docs/principles-and-architecture/thinking-...

Take a look at this. Either you didn't know what's challenging about caching nested graph data, or we have different definitions of triviality/interns.

Re:GraphQL Is a Trap? by arinlen on Friday May 06, 2022 @02:06PM (#31288136)
> Take a look at this.

I repeat: client-side caching is not a problem, even with GraphQL.

The technical problems regarding GraphQL's blockers to caching lies in server-side caching.

For server-side caching, the only answer that GraphQL offers is to use primary keys, hand-wave a lot, and hope that your GraphQL implementation did some sort of optimization to handle that corner case by caching results.

Don't take my word for it. It's really that bad.

https://graphql.org/learn/caching/