Hono client typesafety for APIs with the expand
or include
pattern for relationships
#4140
Unanswered
ashar-nadeem-lumi
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
We're using Hono with Hono client for our REST API as well as data fetching layers. The setup looks something like this:
Now lets say I wanted to include a query param using
zValidator
, likeexpand
. This param would take an array of relations of the admin entity that we want to expand, for example,["businesses", "followers"]
.Altering the query at the DB level is very easy, we'd just selectively join and add those to the select. Even ignoring
zod
for a second, how can we use generics to make Hono client know that if certain values are present in theexpand
query param, the return type of the endpoint changes?Beta Was this translation helpful? Give feedback.
All reactions