Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Nov 20, 2025

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

  • Created new @fern-typescript/react-query-generator package with hook generation logic
  • Added generateReactQueryHooks configuration option to enable/disable the feature
  • Integrated React Query generator into main SDK generation workflow
  • Generated hooks include:
    • Query hooks (useServiceEndpoint) for GET requests
    • Mutation hooks (useServiceEndpointMutation) for POST/PUT/DELETE/PATCH requests
    • Suspense query hooks (useServiceEndpointSuspense) for React 18+ Suspense
    • Infinite query hooks (useServiceEndpointInfinite) for pagination (placeholder)
    • Cache invalidation utilities (invalidateServiceEndpoint, invalidateAllService)
    • Prefetch utilities (prefetchServiceEndpoint)
    • Provider component for SDK client context
  • Added TypeScript project references to ensure correct build order
  • Fixed biome lint errors and upgraded TypeScript to 5.9.3 for compatibility

Testing

⚠️ This PR has not been fully tested with real API definitions

Local verification completed:

  • TypeScript compilation passes (pnpm compile)
  • Dependency checks pass (pnpm depcheck)
  • Biome lint passes (pnpm run check:biome)
  • Unit tests added/updated (none added)
  • Manual testing with generated SDK (not completed)
  • Seed tests added (not included)

Review Checklist

Critical items to review:

  1. Type Safety: The generated hooks use any types extensively. Should these be properly typed based on the IR?

    • UseMutationOptions, UseQueryOptions are not parameterized
    • client: any in prefetch utilities
    • Context value is typed as any | null
  2. Request Parameters: The generated hooks don't properly pass request parameters to SDK methods. Example:

    queryFn: async () => {
        return await client.service.endpoint(); // Missing parameters!
    }

    Should this be implemented or is it intentionally simplified?

  3. Pagination Support: supportsPagination() always returns false, so infinite query hooks are generated but won't work. Is this intentional?

  4. Missing Features:

    • No handling of authentication/request options
    • No error type definitions
    • No query key factories for parameterized queries
    • Provider doesn't validate client type
  5. Build Configuration: Multiple fixes were needed for TypeScript project references. Verify CI passes completely.

  6. Peer Dependencies: Should minimum versions be more specific? Currently uses ^5.0.0 for React Query and ^18.0.0 for React.

Known Limitations

  • Pagination/infinite queries are not fully implemented
  • Type definitions are incomplete (uses any extensively)
  • No seed tests to validate generated code
  • Request parameters are not passed through to SDK methods
  • No documentation or usage examples included

- Add generateReactQueryHooks configuration option to TypescriptCustomConfigSchema
- Create new react-query-generator package for generating React Query hooks
- Implement ReactQueryHooksGenerator for generating useQuery, useMutation, useInfiniteQuery, and useSuspenseQuery hooks
- Implement ReactQueryProviderGenerator for generating provider component
- Integrate React Query generation into SdkGenerator
- Add @tanstack/react-query and react as peer dependencies to generated SDKs
- Export React Query hooks from react-query subdirectory

Co-Authored-By: Niels Swimberghe <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration devin-ai-integration bot changed the title feat(typescript-sdk): add React Query hooks support feat(typescript): add React Query hooks support Nov 20, 2025
- Upgrade TypeScript from 4.6.4 to 5.9.3 to match sibling packages
- Update @types/node to 18.15.3 (exact version)
- Update ts-morph to ^15.1.0 to match sibling packages
- Add @fern-api/configs to devDependencies
- Fix all addImport calls to use correct ImportDeclaration format
- Remove unused dependencies (@fern-api/core-utils, ts-poet)
- Update package.json structure to match sibling packages

Co-Authored-By: Niels Swimberghe <[email protected]>
- Remove unused HttpMethod and VariableDeclarationKind imports
- Format .depcheckrc.json to single line
- Fix code formatting in ReactQueryHooksGenerator.ts and ReactQueryProviderGenerator.ts

Co-Authored-By: Niels Swimberghe <[email protected]>
…erator

- Add react-query-generator to generator's tsconfig.json references
- Ensures react-query-generator is built before SDK generator compiles
- Fixes TS2307 'Cannot find module' error in CI

Co-Authored-By: Niels Swimberghe <[email protected]>
@devin-ai-integration devin-ai-integration bot changed the title feat(typescript): add React Query hooks support feat(typescript-sdk): add React Query hooks support Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant