An unofficial, read-only Hacker News reader.

The Power of GraphQL, Without GraphQL (opens external site)

64 points by Shoetp 5 days ago | cobalt27.dev | 47 comments on HN

View full thread · View on Hacker News

Comment thread (10)

  1. > You lose a lot of that if you just have a GraphQL endpoint.

    Of course, GraphQL was, quite explicitly, intended to be a layer over the CRUD/REST-style endpoints. It is interesting how it tried to become something else once it left the hands of Facebook, but I guess that's par for the course when few have Facebook-type problems but like to latch onto trendy things.

    > And particularly in the age of LLMs and AI where adding and deploying new endpoints can take hours rather than days.

    GraphQL's main value proposition, when humans were still writing code, was providing a map of all the services in the organization to even know what was out there available to use. In a large organization it is easy to not realize that a service exists at all. LLMs can equally benefit from something like that.

    Replies (1)
    1. How is that not covered by rest api docs though?
      Replies (3)
      1. The nature of GraphQL is that you can't write code without an up to date schema.

        You could enforce this in a REST JSON API, of course.

        Replies (1)
        1. Same with some rest backends, FastAPI for example.
      2. With hundreds of different teams all off doing their own thing, how do you read the api docs of a service you don’t know exists? Realistically you’d need some kind of central graph schema to describe all of the available services to facilitate discovery…

        GraphQL was built for the needs of Facebook, not a one man band. A product of Conway’s law.

        Replies (1)
        1. As a counterpoint: while you and other people in this thread are talking about it mostly as a sort of enterprise-tool that helps impose discipline across teams, for me as a lone developer, I have found that schema-first GraphQL has helped me retain clarity.

          Because you can use the schema judiciously to avoid all sorts of problems and to help you visualise the API boundary much more clearly, and rethink it where you need it.

          I also find schema-first stuff quite useful in a prototype context. If I ultimately realise that there are fewer API flows that will matter, and I want to optimise for speed, I can embody those in a JSON API. It's also useful to lay down a framework to anticipate change in a networked app with internal APIs.

          But really any tool that centralises specifications in a way that drives code-generation is potentially a useful thing for a lone developer, because it helps you retain perspective.

          I use it less than I did, but I don't think I would benefit in the same way from this code-first approach from this library.

          Replies (1)
          1. Presumably your "REST-style" services that lie beneath GraphQL also have a schema, so it is not clear what GraphQL really adds if you don't actually have an organization graph to reflect. Navigating a graph of services is computationally inefficient so you'd only ever consider it if your people problems are greater than your compute problems, which was the case for Facebook with thousands upon thousands of developers all trying to work on the same project, but should never be the case for a small organization.
            Replies (1)
            1. > Presumably your "REST-style" services that lie beneath GraphQL also have a schema

              There aren't any "REST services" below the GraphQL layer. I am not using GraphQL as a service orchestration layer on top of REST services. Representing an organisation graph is not the only value of GraphQL.

              > so you'd only ever consider it if...

              > but should never be the case for...

              This is weirdly black-and-white and rather unimaginative thinking.

              I thought about spelling out a more detailed explanation of the situations where I think people miss out on the value of schema-first GraphQL, particularly in content flows or interpreted languages, as a lone developer building complex prototypes/proof of concept/v1 apps, but honestly the tone and tenor of comments here strongly suggests that it isn't worth the typing time. Like with any nuanced discussion of ORMs; HN has orthodox hatreds.

              It may be increasingly in the past for me, at any rate, because of LLMs.

              I don't know if gqlgen-style approaches make as much sense for LLMs because code generation is a significant indirection, and even an intensively schema-first approach like Laravel Lighthouse means asking the LLM to write in an additional language and manage the mapping. Good for me, not for the LLM.

              Plus I am moving on from all interpreted languages at the back end; it no longer makes any kind of sense to deploy PHP, Python or Node apps when you are responsible for the whole deal. The supply chain attack surface is too severe, the internet-facing attack surface is worse, etc.; it's just a recipe for lying awake worrying about the next shell vulnerability.

              Continue this thread (1 replies) →

      3. Even without API docs, REST implemented with HATEOAS in mind has this feature of discovery and self-explanatory. It's not a unique feature of GraphQL.