Effect CommunityEC
Effect Community8mo ago
2 replies
kristo

Integrating `TaggedRequest` with `HttpApi` for a Client in `RequestResolver`

Is it possible to derive a client from HttpApi that takes in a TaggedRequest? I am implementing a caching layer with Persistence and TaggedRequest and RequestResolver, but I also have an HttpApi for the API definition with schemas and error types etc. I'd like to be able to feed my TaggedRequest into a client inside my RequestResolver

https://effect.website/play/#d411134cccb7

Update

I did find platformHttpApi Not Responding to msw-mocked Routes, where Tim says that HttpApiClient is not meant for modeling third party APIs (which is what I am actually doing). If I use HttpClient directly then I can execute it against a url, but I lose the nice mappings that HttpApi gives me from url -> success/error schemas.

I suppose that TaggedRequest already has success/error schemas. So maybe I don't need the HttpApi builder at all. Just have to implement a bit of error handling to go from status codes -> errors.
Was this page helpful?