-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why We aren't using GraphQL
? π
#23
Comments
I hereby invite anyone using If you care about the A couple of years ago, https://about.sourcegraph.com/blog/graphql/graphql-at-twitter https://blog.twitter.com/engineering/en_us/topics/infrastructure/2020/rebuild_twitter_public_api_2020 Seriously, read through this Engineering Blog post. "Latency is a time delay between the cause and the effect of some physical change in the system being observed." ~ https://en.wikipedia.org/wiki/Latency_(engineering)What was Wrong With the "Old" API?The "old" API was perfectly fine. We used it: e.g: dwyl/meteor-search Meanwhile ...Meanwhile, days after Elon acquired the LOSS Making platform, https://developer.twitter.com/en/search-results?q=graphql Coincidence?The whole team of people that worked on Very curious why ... π Sadly, you won't read about the complexity on any of the promotional materials on https://www.graphql.com ... Recommend reading:
Why I Donβt Use GraphQL Anymore: https://youtu.be/S1wQ0WvJK64?t=187 "deep well of complexity" ...if your objective is job security, then definitely implement |
This issue feels like it needs to be in the readme! |
@iteles we could put it in the |
Sadly, Facebook's objective is to:
|
https://bessey.dev/blog/2024/05/24/why-im-over-graphql/ https://www.softwareatscale.dev/p/the-hidden-performance-cost-of-nodejs |
As you can see from the last-updated date on this repo, π§βπ»
we haven't expanded our knowledge of
GraphQL
in a few years. βWe have experience of using
GraphQL
in production in several places. π¦It's universally slower than the equivalent
REST API
orSocket
stream ... πOn the surface it seems like a good idea to model your desired response data in the query. π
You can traverse a graph of data and return the related results. π
What's not to like? π€·ββοΈ
GraphQL
Makes Your App Sloooooooooooooowww ... πOur Experience
We've used
GraphQL
in 3 contexts:Serverless
-AWS Lambda
functions were used to resolve data fromDynamoDB
. These added a minimum of200ms
latency to each query sent from the frontend and in some cases the resolver would take800ms
. This is an unacceptable delay that made every interaction on the Mobile App even on a1Gbps
connection feel Sloooooowww πGraphQL
queries, which then had to be resolved to several other services e.g. 3rd Party APIs. This was a marginal improvement over runningGraphQL
"serverless" but still created duplication of effort because every 3rd Party API required it's own "resolver". There was so much code in the repo and it ended up being so slow it was embarrassing to watch people using the App in demos ... β³ π€¦ββοΈAbsinthe
inElixir
https://github.com/absinthe-graphql/absinthe it was faster than theApollo
Server but instead of defining data in 2 places, now it's 3!! EachGraphQL
endpoint requires it's ownSchema
which then resolves to function that retrieves data fromEcto
... i.e. Maintenance Nightmare! π’Whenever you read the word "modern" think "more complex" or "worse".
Adding a layer of
GraphQL
on top of your existing database means you have to resolve the queries.This means you have to write all code twice and maintain those queries.
When something changes, you have to change and test it in both places.
This automatically increases [in many cases doubles] costs.
And what for? Does it offer a speed boost to the people using the App you're building?
Heck no!! It makes your App slower. In every case.
So why do people keep doing it? π€·ββοΈ
One word:
Fashion π΄οΈ
/fashion-fails
Fashion doesn't have to be practical. It's all about being noticed.
People who are bored and generally don't have much substance to them feel the need to peacock for attention ...
It's no different in the tech world.
Why build a "boring" low-latency API that means people using your App can get their job done faster when you can build a slow API with a "Graph" interface that is substantially slower? Answer: to impress your peers with cool-sounding names. π
Chose the "boring" but fast solution every time.
Leave the complexity to your competitors.
If someone on your team is tempted to use
GraphQL
tell them to create a sample project with non-trivial data and compare the query resolution of theGraphQL
API vs. using "raw" Websockets.There may be a use-case where
GraphQL
is "better", e.g. where you would need to perform multipleREST API
queries to retrieve the same data.Dynamic Data / Response
A use-case that could make sense:
We originally explored using
GraphQL
when we were re-building Search at a travel company where there were multiple parameters such as number of passengers, ages, meal preferences, etc. There wasn't one single API endpoint that could return all the data at once. So we used GraphQL to dynamically build the query in the front-end, assemble all the required bits in the back-end and then the result would have the same "shape" as the query so it would be easier to display.That was the theory at least. The reality was that we were just shifting query complexity from one place to another.
The resolvers in the
GraphQL
server still had to "assemble" all the data to service the query. TheGraphQL
server made as many as 30HTTP
requests to return the needed data from various internal microservices. β³And if you know anything about asynchronous request processing and the theory of constraints, this meant that the response returned by the
GraphQL
server was subjected to the slowest returningHTTP
request. i.e. if one request took1300ms
to return, it didn't matter if the others were200-400ms
the response was always slow.This is a horrible way to build an API!! π
Instead, the way that respects the person/people using the App is to respond as quickly as possible with the most relevant data and then gradually return more data as it become available.
You don't need
Yeezys
to go for a walk outside, you need affordable comfortable & functional shoes.You don't need
GraphQL
to build an API/App. You need something fast that isn't fashionable.If you're building something "kΓΌle" to impress someone, do it as a side-project in your own time.
But please run some benchmarks on it so you know how slow and pointless it is!! π
Build your API around the queries people make most often and optimise for the speed not fashion.
The text was updated successfully, but these errors were encountered: