hey-api / openapi-ts

✨ Turn your OpenAPI specification into a beautiful TypeScript client

Home Page:https://heyapi.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Non-global clients/configs

mothershipper opened this issue · comments

commented

Description

Hi there! Wondering if there are plans to support config/client instances (rather than globals/singletons), or if you'd be open to a pull request that adds that?

Our use case is that for certain APIs we have a dynamic number of client credentials and would feel better about constructing and caching or disposing of the config and clients between uses. I believe we can use interceptors as a workaround currently, but generally we try to avoid global state where we can.

Hey @mothershipper, yes, that sounds like a feature clients will be able to handle.

@mothershipper this is available in the Fetch API client. You can view the demo where I added an example of local client. Would love to hear your thoughts!

commented

Appreciate the quick turn-around, I'll give it a shot today!

commented

Looks like it'll work, thank you!

One ask -- could @hey-api/client-fetch export the FetchClient interface? Right now I'm using ReturnType<typeof createClient>

Sure. I should probably rename it to Client then!

@mothershipper Client interface is exported in v0.1.1