feat(@tanstack/query): add skipToken support#3926
Conversation
|
|
|
Pullfrog stalled The agent stopped emitting events for 302s and was killed by the activity-timeout watchdog. 51 events were processed before the failure. Recent agent stderr
|
|
@nmokkenstorm is attempting to deploy a commit to the Hey API Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: acf29d4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3926 +/- ##
==========================================
+ Coverage 37.32% 37.43% +0.11%
==========================================
Files 656 657 +1
Lines 22536 22567 +31
Branches 6544 6555 +11
==========================================
+ Hits 8411 8449 +38
+ Misses 11459 11454 -5
+ Partials 2666 2664 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@hey-api/codegen-core
@hey-api/json-schema-ref-parser
@hey-api/nuxt
@hey-api/openapi-ts
@hey-api/shared
@hey-api/spec-types
@hey-api/types
@hey-api/vite-plugin
commit: |
…initeQueryOptions, and useQuery hooks
3e2296f to
4681952
Compare
…oken # Conflicts: # packages/openapi-ts/src/plugins/@tanstack/query-core/v5/infiniteQueryOptions.ts # packages/openapi-ts/src/plugins/@tanstack/query-core/v5/plugin.ts # packages/openapi-ts/src/plugins/@tanstack/query-core/v5/queryOptions.ts # packages/openapi-ts/src/plugins/@tanstack/query-core/v5/useQuery.ts
There was a problem hiding this comment.
Reviewed changes — Added skipToken support to TanStack Query plugin generated queryOptions, infiniteQueryOptions, and useQuery hooks. Generated option factories now accept Options<T> | typeof skipToken; when skipToken is passed, queryFn short-circuits and queryKey is built from unwrapped options via a shared unwrapSkipToken helper. Also adds HintMixin to CallTsDsl to support @ts-ignore on call expressions, with accompanying tests.
skipTokensymbol registration —skipTokenis now imported from the TanStack Query package and registered as an external symbol.unwrapSkipTokenhelper — New shared utility function that unwrapsOptions<T> | typeof skipTokentoT | undefined.queryOptions&infiniteQueryOptionsfactories — Parameter type widened toOptions<T> | typeof skipToken;queryFnuses a ternary to returnskipTokenwhen passed; SDK call spreads the unwrapped options instead of the raw parameter.useQueryhooks — Parameter type widened to match the underlyingqueryOptionsfactory.CallTsDslenhancement —HintMixinadded so.hint('@ts-ignore')can be chained on call expressions (used byinfiniteQueryOptions).- Tests — New unit tests for
CallTsDslandTernaryTsDsl; extensive snapshot updates across all TanStack Query flavors.
⚠️ queryKey functions do not accept skipToken
The exported *QueryKey helpers still accept only Options<T>. When skipToken is passed to *Options, the unwrapped undefined is cast back to Options<T> (unwrapped as Options<T>) before being passed to the query-key function. This is safe at runtime because createQueryKey treats undefined as optional, but it means users cannot directly call *QueryKey(skipToken) without a type error. If direct skipToken support in query-key helpers is desired, it should be added in a follow-up.
ℹ️ Nitpicks
infiniteQueryOptions.ts:279— The@ts-ignorehint moved from theinfiniteQueryOptionsobject literal to the call expression. This is a semantic change: previously it suppressed errors on the object shape; now it suppresses errors on the generic inference of the call. Verify this still covers the intended TypeScript error.
Note: 2 inline comment(s) dropped because they did not anchor to lines inside the PR diff:
packages/openapi-ts/src/plugins/@tanstack/query-core/queryKey.ts:179(RIGHT) — file not in PR diffpackages/openapi-ts/src/plugins/@tanstack/query-core/v5/infiniteQueryOptions.ts:279(RIGHT) — file has no textual diff (binary, pure rename, or mode change)
Kimi K2 | 𝕏
There was a problem hiding this comment.
Reviewed changes — Added skipToken support to TanStack Query plugin generated queryOptions, infiniteQueryOptions, and useQuery hooks. Generated option factories now accept Options<T> | typeof skipToken; when skipToken is passed, queryFn short-circuits and queryKey is built from unwrapped options via a shared unwrapSkipToken helper. Also adds HintMixin to CallTsDsl to support @ts-ignore on call expressions, with accompanying tests.
skipTokensymbol registration —skipTokenis now imported from the TanStack Query package and registered as an external symbol.unwrapSkipTokenhelper — New shared utility function that unwrapsOptions<T> | typeof skipTokentoT | undefined.queryOptions&infiniteQueryOptionsfactories — Parameter type widened toOptions<T> | typeof skipToken;queryFnuses a ternary to returnskipTokenwhen passed; SDK call spreads the unwrapped options instead of the raw parameter.useQueryhooks — Parameter type widened to match the underlyingqueryOptionsfactory.CallTsDslenhancement —HintMixinadded so.hint('@ts-ignore')can be chained on call expressions (used byinfiniteQueryOptions).- Tests — New unit tests for
CallTsDslandTernaryTsDsl; extensive snapshot updates across all TanStack Query flavors.
⚠️ queryKey functions do not accept skipToken
The exported *QueryKey helpers still accept only Options<T>. When skipToken is passed to *Options, the unwrapped undefined is cast back to Options<T> (unwrapped as Options<T>) before being passed to the query-key function. This is safe at runtime because createQueryKey treats undefined as optional, but it means users cannot directly call *QueryKey(skipToken) without a type error. If direct skipToken support in query-key helpers is desired, it should be added in a follow-up.
ℹ️ Nitpicks
infiniteQueryOptions.ts:279— The@ts-ignorehint moved from theinfiniteQueryOptionsobject literal to the call expression. This is a semantic change: previously it suppressed errors on the object shape; now it suppresses errors on the generic inference of the call. Verify this still covers the intended TypeScript error.
Note: 2 inline comment(s) dropped because they did not anchor to lines inside the PR diff:
packages/openapi-ts/src/plugins/@tanstack/query-core/queryKey.ts:179(RIGHT) — file not in PR diffpackages/openapi-ts/src/plugins/@tanstack/query-core/v5/infiniteQueryOptions.ts:279(RIGHT) — file has no textual diff (binary, pure rename, or mode change)
Kimi K2 | 𝕏

Summary
Adds
skipTokensupport across the TanStack Query plugin. Generated*Optionsfactories acceptOptions<T> | typeof skipToken; whenskipTokenis passed,queryFnshort-circuits andqueryKeyis built from the unwrapped value via a sharedunwrapSkipTokenhelper. Existing call sites passingOptions<T>continue to work.Independent of #3528. Whichever PR merges first, the other will need a small
useQuery.tsrebase to combine both features.Resolves