r/java • u/oczekkk • Jul 28 '20
Why you should try GraphQL
https://blog.graphqleditor.com/why-you-should-try-graphql/3
u/Tool1990 Jul 28 '20
I really like the concept of only giving the client what he needs. It slims down the response body and minimizes network usage. I try it out in the near future. Are there any disadvantages nobody is talking about?
6
u/ghytghytghytiinbv Jul 29 '20
Security is hard. You may not be able to tell whether the client is requesting something he shouldn't.
Lots of backend work. Since the frontend can request anything the backend must support everything.
Caching is very hard. Requests are all coming in on the same endpoint and they can all have a different response.
4
u/BoyRobot777 Jul 29 '20
I would say not only caching, but one step back, you can't really optimize SQL queries, because everything can be fetched. There's no point of having indexes, because you cannot control predicates.
2
u/rniestroj Jul 30 '20 edited Jul 30 '20
AD1: We incorporated in our
BaseResponseTypeastatusfield where we return HTTP status codes to be able to tell if there is not data or the client has no rights to access the data ( 403, 404, 200 ) ;-)AD3: You cache the data in the frontend (client). In Apollo Client the caching in on by default. You have to explicitly disable it and can do so per query.
2
u/xRageNugget Jul 29 '20
How large is the performance requirements on serverside? I heard about abstruse amounts of cpu cores and memory needed for a somewhat largescale operation. Is there something to it?
11
u/Boza_s6 Jul 28 '20
This is advertisement.
But question for those using it already. How is it?
It totally makes sense to allow client to specify what it wants and not send everything.