Live data from Hacker News

Ask HN: Does Anyone Like GraphQL?

news.ycombinator.com

11–20 of 46 posts

Re: Ask HN: Does Anyone Like GraphQL?

#11
post #7
post #3

Earlier quoted context omitted.

Mostly comparing it to REST. The main turn off for me personally is it really seems like you have to reinvent the wheel to get caching to work correctly with GraphQL for non trivial use cases. Not saying that it works perfectly out of the box if you choose REST instead, but you can get pretty far without needing to optimize anything. Why do you prefer auto-generated GraphQL clients?

auto-generated GraphQL clients works really well if you have a larger codebase and large team. You can think of it as a forced high quality documentation. If you are working in a small project with just a few engs. The additional lift for GraphQL might not be worth it. Especially if the team is not already well versed.

I agree with you there, having GraphQL force adherence to a schema is definitely a good thing for a larger team, but smaller teams will probably get bogged down without previous experience

Re: Ask HN: Does Anyone Like GraphQL?

#12

In my company, we are building a set of monolith applications based on frontend and backend modules that we can compose (Spring jars and React npm packages). As the maintainer of several of those modules, I don't know how my modules will be integrated in each monolith and I don't know exactly how all the complete frontend of each monolith will interact with each API. Having the ability to define small schemas for eac…

This is an interesting use case, I could see why GraphQL would be useful here where the contract between frontend and backend modules is not known in full and can change often.

Out of curiosity, is the reason for the contract between these modules not being fully known / being able to change often because of how your company wants to use them or is there another reason? I'm just wondering if the reason for this is wanting to be able to reuse modules across different projects for multiple clients or writing integrations for other tools or something totally different.

Re: Ask HN: Does Anyone Like GraphQL?

#13
I've only ever found use in GraphQL when it is paired with other technology. Namely Relay (and to some degree Apollo although I'm not as deeply familiar with it as I am with Relay).

Being able to co-locate data queries with components in React has been a huge game changer for me when writing reasonably complex frontend apps. However, GraphQL on its own never struck me as being any more beneficial than Rest.

Re: Ask HN: Does Anyone Like GraphQL?

#14
Like most technologies it depends on how you're using it. When I first starting working in GraphQL, paired with a React frontend I used it in an a similar way to REST, pull the data and then do all the logic of what to display on the frontend.

For me I saw the most benefit when I used the schema to define what to display in the frontend, all the logic of what to display is done on the server and my frontend just becomes simple components that render the pulled schema.

Re: Ask HN: Does Anyone Like GraphQL?

#15

>I have felt strongly that we would have been better off with a more boring approach like REST What led you to this feeling? I know you want to hear from people on why GraphQL is good, but why would REST have been a better choice in that situation? I'm interested as someone who works with both day to day.

REST is simpler to implement and understand.

Re: Ask HN: Does Anyone Like GraphQL?

#16
After the initial hype and adoption, the middle managers who don't code still love it. Every other developer hates it.

Pretty much like Redux or Facebook's ridiculous architecture before that (flux? Something?)

I hear to more and more React and next.js hate everyday as well.

Hopefully this is a sign we're ready for the next great thing in frontend.

Not sure what it will be; personally I moved all the projects I can to solid start.

Re: Ask HN: Does Anyone Like GraphQL?

#17
post #2

I think you have to ask yourself "compared to what?". Compared to REST, I would argue auto-generated GraphQL clients are superior (compared to auto-generated REST clients based on something like OpenAPI). Compared to gRPC, I think it has the advantage that it's much easier to use in the browser and many people seem to prefer text-based protocols for debugability. What are you comparing it to?

What I've been trying out recently is just function calls with arguments from frontend to backend.

It's only for side projects, but I personally prefer this type of approach over both REST and GraphQL.

You just have to think of it as another function.

In addition I define contract using TypeScript code something like this:

defineOperation('getPosts', { input: { filters: dataTypes.array(...) }, output: dataTypes.array(dataTypes.object({ id: dataTypes.uuid(), title: dataTypes.string()}) })

And this generates typed backend function handler and a frontend client function. Backend is TypeScript also, but it could generate for any language in theory.

I also generate database entities like that, and auto create migrations, etc. You could in theory add documentation into that defineOperation as well.

Very simple, and very smooth in my view. Also debuggable since it's text based (using POST method) with json { "operationName": "getPosts", { "filters": ... }}

In frontend I will have a generated, typed function I can use client.getPosts

and in the backend I just have to define export const getPosts: GetPosts = (requestManager) => ... where GetPosts type is generated.

It's because I think REST methods don't make much sense and the endpoints are arbitrary, in the end it's just easier to reason of everything as a function.

I also don't particularly like how GraphQL forces you into this certain mindset, that feels like in many cases it holds you back rather than makes you productive.

Re: Ask HN: Does Anyone Like GraphQL?

#18

Like most technologies it depends on how you're using it. When I first starting working in GraphQL, paired with a React frontend I used it in an a similar way to REST, pull the data and then do all the logic of what to display on the frontend. For me I saw the most benefit when I used the schema to define what to display in the frontend, all the logic of what to display is done on the server and my frontend just beco…

I didn't fully understand what your meant (as I haven't used graphql much), so I asked ChatGPT to explain. It did a decent job, so I figure the answer might help others as well: https://chat.openai.com/share/d708cc93-e920-4b83-b372-83248e...

Re: Ask HN: Does Anyone Like GraphQL?

#19
I was extremely skeptical for years. I've been using it daily for 6 months and I'm surprised how much I like it.

Maybe I was bad at defining REST interfaces. But the interface-definition-language aspect of GQL has been invaluable. It's type safety across the network boundary.

Our server side library auto generates DTO structs to satisfy the schema resolvers. It just removes a lot of boilerplate work when adding routes or new return types.

Re: Ask HN: Does Anyone Like GraphQL?

#20
> Likewise, for much larger more complex projects some of the benefits you can get out of GraphQL can warrant the use of it. But there is a massive gap in the middle where it just seems unnecessary.

I'd say it's optimized for a medium complexity API, in terms of types at least. If you don't know the types in advance, because the users can customize fields somehow, then you can't make a particularly useful GraphQL schema.

There is an underlying assumption that you will have runtime stable objects being queried/mutated.

Post reply on HN