←back to thread

153 points michaelanckaert | 4 comments | | HN request time: 0.675s | source
1. jorams ◴[] No.23486772[source]
In my experience GraphQL can be much nicer to implement than REST, and it offers a good structure around things that many REST APIs implement in particular ways (like selecting which fields you want). The pain you'll experience depends heavily on your data model and the abuse potential that brings.

I think the biggest problem with GraphQL is the JavaScript ecosystem around it, and all of its implicit context. It seems to be built entirely on specific servers and clients, instead of on the general concepts.

Relay[1], a popular client-side library, adds all kinds of requirements in addition to the use of GraphQL. One of those is that until version 8, it required all mutation inputs and outputs to contain a "clientMutationId", which had to be round-tripped. It was an obvious hack for some client-side problem which added requirements to the backend. Somehow it had a specification written for it instead of being fixed before release. This hack is now in public APIs, like every single mutation in the GitHub API v4.

GraphQL also includes "subscriptions", which are described incredibly vaguely and frankly underspecified. There are all kinds of libraries and frameworks that "support subscriptions", but in practice they mean they just support the websocket transport[2] created by Apollo GraphQL.

If you just use it as a way to implement a well-structured API, and use the simplest tools possible to get you there, it's a pleasure to work with.

[1]: https://relay.dev/

[2]: https://github.com/apollographql/subscriptions-transport-ws

replies(1): >>23487135 #
2. kasbah ◴[] No.23487135[source]
I don't think Relay is used that much outside of Facebook. The community seems to have settled on Apollo. Personally I find Apollo over-engineered. When I couldn't delete things from the cache, because of a bug, and was faced with digging into the complex code-base, I ended up just using straight JSON with a HTTP client/fetch and caching in a simple JS object.

Other users of my API [1] just use straight HTTP with JSON as well. GraphQL clients seem to solve something we are not encountering. If urql [2] or gqless [3] work well when I try them I'd be up for changing my mind though.

[1]: https://github.com/kitspace/partinfo

[2]: https://github.com/FormidableLabs/urql

[3]: https://gqless.dev/

replies(2): >>23489401 #>>23493342 #
3. striking ◴[] No.23489401[source]
Relay has quite a few users, a partial list of which you can find at https://relay.dev/en/users. I personally prefer it myself.
4. andrewingram ◴[] No.23493342[source]
Relay has a PR problem and i'm not 100% happy with it, but I've been using it since 2015 (never worked at Facebook) and would still choose it over Apollo. Main reason is that Apollo is geared towards getting up and running easier, but this leads to a worse overall experience beyond that point.