Skip to content

How to call client with dynamic method? #1568

Answered by drwpow
hungify2022 asked this question in Q&A
Discussion options

You must be logged in to vote

This is intentionally difficult to do 🙂. The reason is that you not only have to assert the endpoint dynamically; you also have to handle parameters dynamically, and when you get a response you’re dealing with a union of all your endpoints, which will be an incredibly-hard data shape (don’t forget your error shapes could be different as well as your successes!).

I’d also recommend not using as at all; that’s a footgun that will probably introduce errors that openapi-fetch solves for you, because you’re overriding the type inference.

Type safety is all about static analysis, and what you’re doing by its nature is not statically-analyzable (or at least, not without a lot of discriminated un…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hungify2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants