feat(typescript-sdk): add React Query hooks support #10745
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.
Description
Linear ticket: N/A
Devin session: https://app.devin.ai/sessions/d8ea5a2381f943fd81c630d8b3a19320
Requested by: @Swimburger
Adds React Query (TanStack Query) support to the TypeScript SDK generator, allowing end users to generate React hooks alongside their SDK for easier integration into React applications.
Changes Made
@fern-typescript/react-query-generatorpackage with hook generation logicgenerateReactQueryHooksconfiguration option to enable/disable the featureuseServiceEndpoint) for GET requestsuseServiceEndpointMutation) for POST/PUT/DELETE/PATCH requestsuseServiceEndpointSuspense) for React 18+ SuspenseuseServiceEndpointInfinite) for pagination (placeholder)invalidateServiceEndpoint,invalidateAllService)prefetchServiceEndpoint)Testing
Local verification completed:
pnpm compile)pnpm depcheck)pnpm run check:biome)Review Checklist
Critical items to review:
Type Safety: The generated hooks use
anytypes extensively. Should these be properly typed based on the IR?UseMutationOptions,UseQueryOptionsare not parameterizedclient: anyin prefetch utilitiesany | nullRequest Parameters: The generated hooks don't properly pass request parameters to SDK methods. Example:
Should this be implemented or is it intentionally simplified?
Pagination Support:
supportsPagination()always returnsfalse, so infinite query hooks are generated but won't work. Is this intentional?Missing Features:
Build Configuration: Multiple fixes were needed for TypeScript project references. Verify CI passes completely.
Peer Dependencies: Should minimum versions be more specific? Currently uses
^5.0.0for React Query and^18.0.0for React.Known Limitations
anyextensively)