Skip to content

Conversation

@david-crespo
Copy link
Collaborator

@david-crespo david-crespo commented Nov 12, 2025

These types have kind of been my nemesis since I put them together in #222. Last week I had the revelation that you can use api.methods.siloView.name to get the method name string we need for the query key. I had been passing the method name as a string forever in order to have that string on hand. But if we pass the function directly, inferring the request and response types is trivial: they are just the parameters and return type of the function.

From the callsites, the change looks like this.

- const { data: users } = usePrefetchedQuery(apiq('userList', {}))
+ const { data: users } = usePrefetchedQuery(q(api.userList, {}))

No big deal, just a lot of lines.

@vercel
Copy link

vercel bot commented Nov 12, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
console Ready Ready Preview Nov 13, 2025 3:53pm

<A extends ApiClient>(api: A) =>
<M extends string & keyof A>(
method: M,
params: Params<A[M]>,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good riddance!

@david-crespo david-crespo merged commit 439c7dd into main Nov 13, 2025
7 checks passed
@david-crespo david-crespo deleted the redo-api-helpers branch November 13, 2025 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants