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.
Ask HN: Does Anyone Like GraphQL?
11–20 of 46 posts
Re: Ask HN: Does Anyone Like GraphQL?
#12In 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…
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?
#13Being 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?
#14For 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.
Re: Ask HN: Does Anyone Like GraphQL?
#16Pretty 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?
#17I 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?
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?
#18Like 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…
Re: Ask HN: Does Anyone Like GraphQL?
#19Maybe 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?
#20I'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.