Conversation
…upport Resolved by keeping the v3 ts-morph pipeline structure: - src/service.mts and tests/service.test.ts taken from main (proven against 0.99 sdk.gen output) - src/generate.mts taken from main (0.99 plugins config incl. operations.nesting migration) - Old-architecture files remain deleted (createExports/createImports/createUseQuery/createUseMutation) - Snapshots regenerated: hey-api 0.92+ exports the Error schema under its original name (was _Error in 0.73) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- TError defaults fall back to unknown (AxiosError<unknown> for axios) when
the operation has no generated Error type (e.g. no error responses defined)
- allParamsOptional now uses the SDK function's parameter optionality as the
authoritative check; in 0.92+ the options parameter is required when the
operation has required path params, so hooks no longer emit an invalid
`= {}` default
- Drop redundant client.setConfig from the react-app example; axios.ts
already configures baseURL
Verified: 153 unit tests pass and all 5 example apps typecheck their
regenerated output (test:generated).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ted hooks - Import Options from ../requests/sdk.gen instead of ../requests/client; the sdk.gen Options is extended with `client` and `meta`, which v2 hooks accepted (per-request client override would fail to typecheck otherwise) - Emit the operation's JSDoc (description and @deprecated) on every generated hook, matching v2 output With this, regenerated output for all 5 example apps is semantically identical to v2.2.0 — remaining diffs are import statement merging and blank lines only. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Prerelease tags publish to the beta dist-tag so latest keeps pointing at the current stable release. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ted infinite query keys queryOptions.ts (#173): - Every GET operation gets a queryOptions() factory (e.g. findPetsOptions) usable with useQuery, useQueries, prefetchQuery, ensureQueryData, setQueryData and other TanStack Query utilities with full type safety - Paginatable operations get an infiniteQueryOptions() factory with initialPageParam/getNextPageParam wired to the CLI options; numeric initialPageParam is emitted as a number literal so the inferred pageParam type matches getNextPageParam Dedicated infinite query keys (#140): - Infinite hooks and factories now use use<Op>InfiniteKey ("<Op>Infinite") and Use<Op>InfiniteKeyFn, so cached InfiniteData no longer collides with the plain query cache for the same operation - The infinite client options type excludes the page parameter, which is supplied by TanStack Query's pageParam mechanism; specs with a required page parameter now compile BREAKING CHANGE: useInfiniteQuery hooks changed their cache key from Use<Op>KeyFn to Use<Op>InfiniteKeyFn and no longer accept the page parameter in clientOptions. Verified: 165 unit tests pass; all 5 example apps regenerate and typecheck (test:generated). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…af 6, lefthook 2) - Migrate biome config to 2.x (tailwindDirectives, svg exclusion, example rule overrides) - Remove dead code surfaced by biome 2 noUnusedVariables/noUnusedImports - Keep TypeScript on 6.x (ts-morph 28 does not support the TS 7 native compiler yet)
…mmander range Closes #134
Infinite query keys now share the plain query key as their first segment (["FindPets", "infinite", params] instead of ["FindPetsInfinite", params]), so invalidating [useFindPetsKey] matches both the plain and infinite cache entries of an operation while cached InfiniteData still never collides with plain query data. BREAKING CHANGE: useXxxInfiniteKey is now a readonly tuple instead of a string. Closes #174 Refs #140
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- Generate prefetchUseXxxInfinite via queryClient.prefetchInfiniteQuery for SSR hydration of paginated lists (#155) - Generate useXxxSuspenseInfinite hooks sharing the infinite cache key - Accept TanStack Query options in prefetch and ensure functions (#157) - Call the SDK with throwOnError: true everywhere so error responses reject instead of resolving undefined data; fixes ensureQueryData caching undefined and error states never firing (#172) Closes #155 Closes #157 Closes #172
…il, Renovate - README: feature overview with queryOptions-first positioning, comparison with the hey-api tanstack-query plugin and Orval, stability policy, requirements, quick start - Contributing guide and AGENTS.md: document the exact-pin + patch upgrade workflow for hey-api and the OperationInfo/GenerationContext IR boundary that keeps the generation layer backend-portable - Add renovate.json: grouped hey-api update PRs (snapshot suite as the breaking-change detector) and grouped non-major dev tooling updates
…output
Review cleanup of the recent feature work:
- Extract SDK_CALL_ARGS, buildPagedQueryFn, formatInitialPageParam,
buildGetNextPageParamExpr, buildInfiniteClientOptionsParam, and
buildOverridableInfiniteOptionsType so the throwOnError call shape and the
infinite-query templates live in one place instead of ten
- Merge buildUseInfiniteQueryHook / buildUseSuspenseInfiniteQueryHook into one
parameterized implementation
- Emit initialPageParam as a numeric literal in hooks too, matching the
factories and prefetch functions (server-prefetched page 1 now hydrates the
same pageParam the client refetches with)
- Give prefetchUseXxxInfinite the same options passthrough as its siblings,
which also makes the FetchInfiniteQueryOptions import real
- Reuse buildClientOptionsParam / getDataTypeName in prefetch, ensure, and
queryOptions builders instead of inlined copies
- generateIndexFile returns its constant content without a ts-morph project;
suspense/prefetch loops filter paginatable operations up front
- examples: use key={pet.id} instead of array-index keys and drop the
noArrayIndexKey override
- Point the install command at ^3 instead of the beta tag - Call out the throwOnError behavior change in the TL;DR (the one change the compiler cannot catch) - Document the options parameter on prefetchUseXxxInfinite
Exercises the generated queryOptions factories, ensureQueryData, prefetchInfiniteQuery, hierarchical key invalidation, and the throwOnError behavior (#172) with real requests instead of type checks only. Runs in CI after the example codegen step.
…wOnError workaround - nextjs-app: prefetch the first infinite page on the server with prefetchUseFindPaginatedPetsInfinite + HydrationBoundary - react-app / react-router-6-app: remove the client-level throwOnError workaround — v3 generated code sets it per call (#172)
`safeParseNumber` relied on `Number(value)`, and `Number("")` evaluates to
0. As a result `formatOptions` coerced `--initialPageParam ""` into a
numeric 0, so the generated infinite queries sent `page=0` instead of the
blank first page the API expected.
Treat blank strings as NaN so `formatOptions` falls through to the
passthrough branch and keeps the original value. All four infinite
surfaces (hook, suspense hook, prefetch, queryOptions factory) now emit
`initialPageParam: ""`.
Closes #177
`generateFiles.mts` imported `StructureKind` but never referenced it, so Biome reported a noUnusedImports warning. The file only needs the `ImportDeclarationStructure` type, so collapse the statement into a plain type-only import.
Some APIs expect no page parameter (or an empty one) on the first request of a paginated endpoint. Previously the only knob was --initialPageParam, which always emits a concrete value. With --omitInitialPageParam the generated infinite queries emit `initialPageParam: undefined` and spread the page param into the request only once TanStack Query supplies one, so the first request carries no page param at all. The flag overrides --initialPageParam. Verified end-to-end: the generated output typechecks against the example app (TanStack Query infers TPageParam as `number | undefined`, so `initialPageParam: undefined` is valid) across all four infinite surfaces (hook, suspense, prefetch, queryOptions factory). Refs #177
The react-app example targets the hey-api fetch client, whose Config
expects `baseUrl` (not axios-style `baseURL`) and which throws the
OpenAPI `Error` schema body (`{ code, message }`) rather than an axios
error with a `.response` property.
- src/axios.ts, verify-runtime.test.ts: pass `baseUrl` to
`client.setConfig` — the `baseURL` typo silently left the client
unconfigured, so runtime tests hit the default URL instead of the
in-process test server
- src/App.tsx: read `error.message` directly instead of the
nonexistent `error.response?.data.message`
`npx tsc -p ./tsconfig.json --noEmit` in examples/react-app is now
clean and verify-runtime.test.ts passes 6/6 locally.
…react-app" This reverts commit e65134d.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
v3 is a full rewrite of the code generator on top of a ts-morph pipeline. Generated output stays intentionally compatible with v2 except for infinite queries and error handling. See the migration guide for details.
Highlights
useQuery,useQueries,prefetchQuery,ensureQueryData, andsetQueryDatawith full type safety.useXxxInfinite,useXxxSuspenseInfinite, andprefetchUseXxxInfinitefor SSR hydration of paginated lists (Support prefetchInfiniteQuery #155).["FindPets", "infinite", params]): invalidating[useFindPetsKey]now matches both the plain and infinite cache entries of an operation, while cachedInfiniteDatanever collides with plain query data (Generated query key functions don't allow for granular query invalidation, especially with pagination #174, Generates incorrect queryKeys for Infinite queries #140).initialPageParamandgetNextPageParamare no longer required in the generated options type and can be overridden for custom pagination schemes (InfiniteQueryOptions should omitinitialPageParamandgetNextPageParam#156, Allow pageParam to be a string within generated infiniteQueries #146, Issues with generating custom pagination infinite queries #139).throwOnError: true, so error states actually fire andensureQueryDatano longer cachesundefined(ensureQueryData incorrectly handlesthrowOnError#172).prefetchUseXxx(queryClient, clientOptions, options?)andensureUseXxxData(...)accept TanStack Query options (Support specifying options in prefetch #157).@tanstack/react-querydeclared as a peer dependency (^5) and commander 12–15 accepted (List react-query v4 as a peer dependency #134).Breaking changes
useXxxInfiniteKeyis now a readonly tuple instead of a string.clientOptionsfor infinite hooks.undefineddata (behavior fix, ensureQueryData incorrectly handlesthrowOnError#172).All covered in the migration guide with mechanical fixes.
Test plan
vitest run)biome checkandtscbuild clean{ enabled: false }), pagination overrides, prefetchInfiniteQuery, suspense infinite hooks, and prefetch/ensure optionsChanges since beta.3 (shipped in v3.0.0-beta.4, 2026-07-19)
initialPageParamis preserved (I'm running into a problem withinitialPageParamhere. My api expects no or an empty initial page parameter.initialPageParam=""generates code that sendspage=0. I believe the reason is thatformatOptions => safeParseNumberconverts the empty string to0. #177):Number("")is0, soformatOptionsused to coerce--initialPageParam ""into a numeric0and the generated infinite queries sentpage=0. Blank and whitespace-only strings are now kept as-is; theinitialPageParam="''"workaround is no longer needed.--omitInitialPageParamflag (I'm running into a problem withinitialPageParamhere. My api expects no or an empty initial page parameter.initialPageParam=""generates code that sendspage=0. I believe the reason is thatformatOptions => safeParseNumberconverts the empty string to0. #177): emitsinitialPageParam: undefinedand spreads the page param into the request only once TanStack Query supplies one, so the first request carries no page parameter at all. Overrides--initialPageParam. Useful for APIs that expect no (or an empty) page parameter on the first request.Both verified end-to-end across all four infinite surfaces (hook, suspense hook, prefetch,
infiniteQueryOptionsfactory); unit suite is now 180 tests.