Re:Why, after 6 years, I'm over GraphQL
by teaearlgraycold on Thursday May 30, 2024 @02:28PM
(#40527103)
I think a lot of people like GraphQL because it provides strongly typed API interfaces. But I've been able to hack together a better REST alternative in full-stack typescript codebases. And my solution doesn't need to compile any kind of client or intermediary.
[ Parent
| on HN ]
You can type your REST API too. https://restfulapi.net/json-schema/
GraphQL gives you the ability to compose fragments, so if the UserDetail component and UserPaymentInfo component both use the user’s name, it is loaded once.
With ad hoc solutions like tRPC, you end up fetching the same field multiple times (and probably doing some sort of network waterfall), or you give up on data masking and composability. And if you have enough engineers, data masking and composability are critical to maintain velocity.
Re:Why, after 6 years, I'm over GraphQL
by teaearlgraycold on Thursday May 30, 2024 @05:11PM
(#40528759)
swr can handle the first issue you mentioned just fine.
I'm not sure I follow. Are you saying swr allows for fragments and deduplication?
If you don't have fragments (in particular, if you have a single call to an swr hook at the root), then you have implicit deduplication. But then you run into the issue of it being unclear whether you can remove a given field when a subcomponent stops using it — you have to check whether any other subcomponent happens to use that.
And if you have many separate queries, you're architecting in waterfalls. But you have clarity about who uses which field.
Re:Why, after 6 years, I'm over GraphQL
by teaearlgraycold on Thursday May 30, 2024 @07:43PM
(#40530020)
I think you updated your comment.