Skip to content

feat(@tanstack/query): add skipToken support#3926

Open
nmokkenstorm wants to merge 3 commits into
hey-api:mainfrom
nmokkenstorm:feat/tanstack-skiptoken
Open

feat(@tanstack/query): add skipToken support#3926
nmokkenstorm wants to merge 3 commits into
hey-api:mainfrom
nmokkenstorm:feat/tanstack-skiptoken

Conversation

@nmokkenstorm
Copy link
Copy Markdown
Contributor

@nmokkenstorm nmokkenstorm commented May 25, 2026

Summary

Adds skipToken support across the TanStack Query plugin. Generated *Options factories accept Options<T> | typeof skipToken; when skipToken is passed, queryFn short-circuits and queryKey is built from the unwrapped value via a shared unwrapSkipToken helper. Existing call sites passing Options<T> continue to work.

Independent of #3528. Whichever PR merges first, the other will need a small useQuery.ts rebase to combine both features.

Resolves

@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@pullfrog
Copy link
Copy Markdown
Contributor

pullfrog Bot commented May 25, 2026

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
INFO  2026-05-25T13:03:43 +50ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:43 +4ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:43 +22ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:43 +26ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:43 +27ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:43 +25ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:43 +28ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:43 +23ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:43 +26ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:43 +25ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:43 +27ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:43 +24ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:43 +26ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:43 +28ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:43 +25ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:43 +27ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:43 +23ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:43 +27ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:44 +26ms service=bus type=message.part.delta publishing
INFO  2026-05-25T13:03:44 +24ms service=bus type=message.part.delta publishing

Pullfrog  | Rerun failed job ➔View workflow run | via Pullfrog | Using Kimi K2𝕏

@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

@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-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 25, 2026

🦋 Changeset detected

Latest commit: acf29d4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hey-api/openapi-ts Minor

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
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.43%. Comparing base (4fb57c5) to head (acf29d4).

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     
Flag Coverage Δ
unittests 37.43% <ø> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 25, 2026

Open in StackBlitz

@hey-api/codegen-core

npm i https://pkg.pr.new/@hey-api/codegen-core@3926

@hey-api/json-schema-ref-parser

npm i https://pkg.pr.new/@hey-api/json-schema-ref-parser@3926

@hey-api/nuxt

npm i https://pkg.pr.new/@hey-api/nuxt@3926

@hey-api/openapi-ts

npm i https://pkg.pr.new/@hey-api/openapi-ts@3926

@hey-api/shared

npm i https://pkg.pr.new/@hey-api/shared@3926

@hey-api/spec-types

npm i https://pkg.pr.new/@hey-api/spec-types@3926

@hey-api/types

npm i https://pkg.pr.new/@hey-api/types@3926

@hey-api/vite-plugin

npm i https://pkg.pr.new/@hey-api/vite-plugin@3926

commit: acf29d4

@nmokkenstorm nmokkenstorm force-pushed the feat/tanstack-skiptoken branch from 3e2296f to 4681952 Compare May 25, 2026 14:03
@nmokkenstorm nmokkenstorm changed the title feat(@tanstack/query): add skipToken support to queryOptions and infiniteQueryOptions feat(@tanstack/query): add skipToken support May 26, 2026
…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
@nmokkenstorm nmokkenstorm marked this pull request as ready for review May 29, 2026 14:02
@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. feature 🚀 Feature request. labels May 29, 2026
Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

  • skipToken symbol registrationskipToken is now imported from the TanStack Query package and registered as an external symbol.
  • unwrapSkipToken helper — New shared utility function that unwraps Options<T> | typeof skipToken to T | undefined.
  • queryOptions & infiniteQueryOptions factories — Parameter type widened to Options<T> | typeof skipToken; queryFn uses a ternary to return skipToken when passed; SDK call spreads the unwrapped options instead of the raw parameter.
  • useQuery hooks — Parameter type widened to match the underlying queryOptions factory.
  • CallTsDsl enhancementHintMixin added so .hint('@ts-ignore') can be chained on call expressions (used by infiniteQueryOptions).
  • Tests — New unit tests for CallTsDsl and TernaryTsDsl; 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-ignore hint moved from the infiniteQueryOptions object 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 diff
  • packages/openapi-ts/src/plugins/@tanstack/query-core/v5/infiniteQueryOptions.ts:279 (RIGHT) — file has no textual diff (binary, pure rename, or mode change)

Pullfrog  | Fix it ➔View workflow run | Using Kimi K2𝕏

Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

  • skipToken symbol registrationskipToken is now imported from the TanStack Query package and registered as an external symbol.
  • unwrapSkipToken helper — New shared utility function that unwraps Options<T> | typeof skipToken to T | undefined.
  • queryOptions & infiniteQueryOptions factories — Parameter type widened to Options<T> | typeof skipToken; queryFn uses a ternary to return skipToken when passed; SDK call spreads the unwrapped options instead of the raw parameter.
  • useQuery hooks — Parameter type widened to match the underlying queryOptions factory.
  • CallTsDsl enhancementHintMixin added so .hint('@ts-ignore') can be chained on call expressions (used by infiniteQueryOptions).
  • Tests — New unit tests for CallTsDsl and TernaryTsDsl; 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-ignore hint moved from the infiniteQueryOptions object 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 diff
  • packages/openapi-ts/src/plugins/@tanstack/query-core/v5/infiniteQueryOptions.ts:279 (RIGHT) — file has no textual diff (binary, pure rename, or mode change)

Pullfrog  | Fix it ➔View workflow run | Using Kimi K2𝕏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature 🚀 Feature request. size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

skip-token support

1 participant