News for hackers. Stuff that matters.
Re:Why use GraphQL, good and bad reasons by boubiyeah on Friday August 24, 2018 @01:14PM (#17836244)
Another PRO of strict APIs is that they're dead simple to cache. Tons of customization = caching hell.
Re:Why use GraphQL, good and bad reasons by tylerhou on Friday August 24, 2018 @01:54PM (#17836541)
If you know your queries at compile time, then you can register each query with the server when you build as the hash of the query. Then clients only have to send up the hash and the server can look them up in its registry; plus you now have an easy way to cache (cache based on query hash plus user). If it's the first time you've seen a query, you can hash it and add it to the registry as well.

See: https://github.com/apollographql/apollo-link-persisted-queri... https://blog.apollographql.com/improve-graphql-performance-w...

Re:Why use GraphQL, good and bad reasons by boubiyeah on Friday August 24, 2018 @02:03PM (#17836614)
I know about apollo caching, but it's strictly inferior to HTTP caching which has tons of options (Vary, Etag, etc)

Caching per user is still going to mean tons of cache misses. Caching based on the query hash means you're going to cache subsets of the same data over and over as separate entries.

With resources over HTTP, you can separate the user specific part from the generic resource part and cache accordingly.

Plus, I like the option of caching somewhere else than the app server, like a distributed Varnish.

I'm not saying you can't cache with graphQL, it's just less natural and mature.

Re:Why use GraphQL, good and bad reasons by RussianCow on Friday August 24, 2018 @04:11PM (#17837559)
In practice, caching is non-trivial to implement for any sufficiently complex system even with REST. It depends on your use case of course, and how tolerant you are of stale data, but I have worked on very few frontends where HTTP caching is sufficient.