15

Am i the only one who doesnt see how graphql is useful? Yeah you can cut back on data transfer and let the server do the parsing but like, you can do the same if you spend 3 minutes properly designing the backend?

Comments
  • 3
    Same here.

    Although, I made a client app that consumed a Graphql API. It was a bit difficult to know all the object names and nest them properly. I think it's more work for something that could be achieved using normal REST APIs.

    For example, to achieve transferring less data, you can design your API response using something like the decorator pattern.
  • 2
    @oudalally you can return JSON objects in either GraphQL or classic REST APIs.

    @sharktits for small projects I'd say there's not much difference, but for larger ones it may be a big deal. Imagine a SQL database with tens of models / schemes and even more possible combinations of requests possible.

    Ex.: First 10 Users' Posts which have more than X Comments ordered by [insert whatever model here]. To make a custom request like that in REST, either the API has an endpoint for that (which may be unlikely), or an application has to fetch each model separately and scavenger through it locally, which takes time and bandwidth.

    GraphQL is a querying language to minimize this problem. It makes much more intelligent requests than "let's fetch everything and filter locally".

    In addition to that, you can query only the attributes you really want from the models. No useless data will be passed if you didn't ask for it (like a whole Post text instead of just the title and author).
  • 0
    @oudalally

    It's just an object that works as a wrapper for my main object (a database record for example) that whole responsibility is to extract and present my main object the way I want it to look like.

    Also, I think what I described is called the presenter pattern but I've seen both terms used to describe the same thing (at least in domain of wrapping a main object into another).
  • 0
    Not a proper question coming from you.

    Tell me, if you are not using grapgql, then how are you gonna tell people that you use it?

    Its about being trendy man!
  • 0
    We're using graphql for our main project. It's really comfortable when it comes to database queries, as you now have the possibility to select certain rows from the frontend, preventing useless queries and straight up making the whole Get-requesting a whole lot of easier - especially when reusing some queries over and over again
  • 0
    @jackconnorhull that doesnt answer my question, in fact, that is the question but worded differently.
Add Comment