Live data from Hacker News

Ask HN: Does Anyone Like GraphQL?

news.ycombinator.com

41–46 of 46 posts

Re: Ask HN: Does Anyone Like GraphQL?

#41
post #37

GraphQL doesn't allow for recursive types. This limitation cropped up in a project and was a frustrating (re)discovery. You have to pick a maximum depth and explicitly define that depth. It abuses POST. No way to tell by a quick glance at the network tab the purpose of a request. Whichever team controls the implementation of the resolvers decides the return structure which may be less than ideal for the front end tea…

> GraphQL doesn't allow for recursive types. It does, this schema works: type Item { id: ID! children: [Item!]! } type Query { root: Item! } GraphQL queries describe the shape of the response, so with this schema it's not possible to ask recursively for "the full tree up to an arbitrary depth". One way to solve this would be to add a "descendants" field that returns a list of all the children, grand-children...

It is not infinitely recursive. It supports nested structures as you show but only up to a predefined depth.

IE:

    fragment CategoriesRecursive on Category {
      subcategories {
        ...SubcategoryFields
        subcategories {
          ...SubcategoryFields
          subcategories {
            ...SubcategoryFields
          }
        }
      }
    }

So you have to build your schema with a maximum supported depth. This is not infinitely recursive which is a limitation of the GQL type system.

Re: Ask HN: Does Anyone Like GraphQL?

#42
It actually has a very narrow use - traffic heavy (mostly end user) clients with complex data to fetch. I.e. facebook.

But then you got cargo cult thing and now we get what we get.

On a positive side - it reduces unemployment :)

Re: Ask HN: Does Anyone Like GraphQL?

#44
I like it on paper.

In practice, not so much but mostly due to teams not using it properly or leveraging it in a way that actually makes sense. I've seen teams implement gql for something that was used by 1 consumer (another service) that asked for the entire fields in payload anyway.. at least someone got promoted (I would not have promoted them for using the wrong tool for the job, when the right tool would have allowed them to ship faster).

Re: Ask HN: Does Anyone Like GraphQL?

#46

Used it in multiple companies, never said "Wow this is great!" - always said "fuck this would be 10x simpler in REST". The only benefit I have personally experienced is that since we have mobile apps more often than not with Apollo, having the graphql for both mobile _and_ web react is nice. But with Phoenix Liveview that benefit quickly erodes for me. I say good riddance.

It would be cool have Phoenix controllers feeding the LiveView, and also generating a JSON API.
Post reply on HN