Replies: 2 comments 5 replies
-
Thanks, let's start here!
You can absolutely configure token for all requests without MyClient. You can modify the
The current answer is the new Fetch API client – make sure to view the demo too. A similar solution will be offered for other clients.
There are a few reasons.
As a result, custom instances suffer from unique bugs that aren't present in the default approach, see #517. It's harder to prioritise such issues without knowing how many people use each approach. And even then, it's not reasonable to offer multiple API surfaces like that. If you're a new person using this package and follow the guide, as soon as you want to add another backend service, you have to rewrite all your code because the original approach didn't encapsulate everything in a client instance. Finally, the new APIs are superior. Whether it's offering tree-shaking, customisable client instances per request, access to headers and raw request/response, or deduplicated parameter definitions. The only thing client instances got going for them is an SDK-like API encapsulation of all endpoints. That's a valid feature, but would be better addressed by generating a proper SDK, or perhaps offering a different signature to default clients. Tl;dr standalone clients are easier to maintain, offer more features, and result in a faster and consistent generated code. |
Beta Was this translation helpful? Give feedback.
-
Started an issue around full SDKs, let's move the conversation there #926 |
Beta Was this translation helpful? Give feedback.
-
See #606 (comment) for a related issue.
The issue
name
in configuration is deprecated, and will eventually be removed. Without that configuration, the default class won't be created.Consider this example –
In this example,
MyClient
is the default client that is created only whenname
is specified, and it offer a nice wrapper for the base request configuration – this lets us set up the token.test
is a service, andgetThings
is an API endpoint.Without
MyClient
generated, there is no straightforward way to configure the token for all requests.@mrlubos and the rest of the hey-api team – can you folks please add more information about a) why this is being deprecated and b) what the client configuration API will look like once
name
option is gone?Beta Was this translation helpful? Give feedback.
All reactions