You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
v4's @kubb/plugin-client had this via dataReturnType: 'data' | 'full'. v5 removed it when
splitting plugin-client into pluginAxios/pluginFetch behind the shared RequestResult
contract (migration guide). Request: reintroduce an equivalent on pluginAxios — a client.returnType: 'full' | 'data'
option so a generated operation's promise can resolve directly to data instead of the full { status, data, error, contentType, request, response } object.
Motivation
Default throwOnError: true means every resolved promise is already a success — status/error/contentType/request/response add no information the caller doesn't
already have.
Every call site writes result.data / destructures { data } to reach the one field that
actually varies.
No option today makes the call resolve directly to the body. Workarounds: a hand-rolled unwrap() per call site, or patching the generated .kubb/client.ts (copied verbatim from templates/axios.ts, not owned by the consumer) — fragile against template changes.
'data': resolves directly to success data when throwOnError: true. Under throwOnError: false, stays full in both branches — data alone can't distinguish
success/failure once errors stop throwing.
Type-level: ThrowOnError extends true branch → DataOf<SuccessOf<TResponses>> instead of SuccessResultUnion<...> (both already exist internally in templates/axios.ts).
// returnType: 'data'constinvoice=awaitpostInvoiceRequest({ body });// PostInvoiceRequestResponse directly// returnType: 'full' (default)constinvoice=(awaitpostInvoiceRequest({ body })).data;
Ship unwrap() as a runtime helper — opt-in per call, not a package-wide default.
Backwards compatibility
Fully opt-in; default ('full') unchanged. Only consumers setting returnType: 'data' are
affected.
Open questions
Why was dataReturnType mandated for removal in v5 rather than carried onto pluginAxios/pluginFetch? Tied to the shared RequestResult contract's design
(type-inference cost, ambiguity under throwOnError: false), or purely a scope call during the plugin-client split with no objection to a narrower version returning?
Naming: returnType vs. dataOnly / unwrap / resultShape.
Should 'data' also apply under sdk: true (class-based output)?
Does this belong on pluginAxios directly, or a shared base option other transport plugins
could reuse?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Summary
v4's
@kubb/plugin-clienthad this viadataReturnType: 'data' | 'full'. v5 removed it whensplitting
plugin-clientintopluginAxios/pluginFetchbehind the sharedRequestResultcontract (migration guide).
Request: reintroduce an equivalent on
pluginAxios— aclient.returnType: 'full' | 'data'option so a generated operation's promise can resolve directly to
datainstead of the full{ status, data, error, contentType, request, response }object.Motivation
throwOnError: truemeans every resolved promise is already a success —status/error/contentType/request/responseadd no information the caller doesn'talready have.
result.data/ destructures{ data }to reach the one field thatactually varies.
unwrap()per call site, or patching the generated.kubb/client.ts(copied verbatim fromtemplates/axios.ts, not owned by the consumer) — fragile against template changes.Proposed API
'full'(default): unchanged.'data': resolves directly to successdatawhenthrowOnError: true. UnderthrowOnError: false, stays full in both branches —dataalone can't distinguishsuccess/failure once errors stop throwing.
ThrowOnError extends truebranch →DataOf<SuccessOf<TResponses>>instead ofSuccessResultUnion<...>(both already exist internally intemplates/axios.ts).Alternatives considered
postInvoiceRequestData) — doubles the generated surface,default stays noisy.
unwrap()as a runtime helper — opt-in per call, not a package-wide default.Backwards compatibility
Fully opt-in; default (
'full') unchanged. Only consumers settingreturnType: 'data'areaffected.
Open questions
dataReturnTypemandated for removal in v5 rather than carried ontopluginAxios/pluginFetch? Tied to the sharedRequestResultcontract's design(type-inference cost, ambiguity under
throwOnError: false), or purely a scope call during theplugin-clientsplit with no objection to a narrower version returning?returnTypevs.dataOnly/unwrap/resultShape.'data'also apply undersdk: true(class-based output)?pluginAxiosdirectly, or a shared base option other transport pluginscould reuse?
All reactions