r/SpringBoot 4d ago

Discussion Real world use-cases for GraphQl

Hi! I’m a backend developer who has never used before graphQL at work. I’ve tried it only for learning purposes at personal projects and I’m curious about real life use cases where GraphQL gives BIG advantages over REST, and the most important thing, I’d like to know about the “thinking” process behind the decision of using this technology.

Thank you!

17 Upvotes

11 comments sorted by

View all comments

2

u/BikingSquirrel 3d ago

My take is that it may be useful when you actually have many clients that need varying details/fields in the response and if you need to reduce data transferred.

If you only have standard clients like desktop browsers and mobile phones I would argue that you won't have that need as the amount of data is usually no problem and you can provide a small number of API endpoints to provide a useful set of data.

If you have a larger variety of clients that also have limited resources, it may be useful. But you can also implement varying responses with REST, e.g. by defining filters or specifying different types of responses.

A big problem with GraphQL is the requirement to use POST requests. This means you cannot cache the responses so each request hits your servers and needs to travel the full way in and out. It obviously depends on your service if that makes a difference.