Hacker News new | ask | show | jobs
by DidYaWipe 416 days ago
Why would you hard-code queries into your client application?
1 comments

I never said anything of the sort, what are you talking about?
"...an automatic CRUD API. And I don't see what's the dilemma here. Just use a normal endpoint. Keep using PostgREST to save time."
Where in my message does it say or imply that you should “hard code queries in your client application?”?

EDIT: What I’m advocating here is the opposite: use those tools for CRUD so that your frontend looks exactly the same as a frontend with a regular backend would. If the tool is not good for it (like the example), just use a regular endpoint in whatever backend language or framework. Don’t throw the baby (the 95%) with the bathwater (the 5%).

By “just use a normal endpoint” I mean “write a normal backend for the necessary cases”.

Of what use is an "automatic CRUD API" if you're not putting query logic in your client application?
With Supabase or Hasura you would write the same client code you would write if you were using a traditional backend.

At least when used correctly, but honestly I can’t see a situation where it’s easy to do otherwise for queries.

The utility is in not having to write a lot of repetitive endpoints in a traditional backend, for a large amount of endpoints.

What exactly do you mean by “query logic in the client code”?

I mean instead of doing a GET on an endpoint called userMessages with an ID parameter, you're formulating a join in the client between specific tables.