Skip to content

Conversation

@pyramation
Copy link
Contributor

Summary

Adds a reactQuery.enabled configuration option to control whether React Query hooks are generated. When disabled (the default), only standalone fetch functions are generated, removing the React/React Query dependency from generated code.

Key changes:

  • New reactQuery.enabled config option (defaults to false)
  • Query generators conditionally skip useQuery hooks and React Query imports when disabled
  • Mutation generators return null when disabled (mutations require React Query)
  • Standalone fetchXxxQuery functions are always generated regardless of setting
  • README updated to fix incorrect package name (@constructive-io/graphql-sdk@constructive-io/graphql-codegen) and added header/badges to match other packages

Review & Testing Checklist for Human

  • BREAKING CHANGE: Verify that reactQuery.enabled: false as the default is intentional. Existing users upgrading will no longer get React Query hooks unless they explicitly set reactQuery: { enabled: true } in their config.
  • Verify mutation behavior is acceptable: when React Query is disabled, NO mutation files are generated at all (not just hooks removed)
  • Test full codegen pipeline end-to-end with both reactQuery.enabled: true and reactQuery.enabled: false to ensure generated code compiles and works correctly
  • Confirm the README package name fix from @constructive-io/graphql-sdk to @constructive-io/graphql-codegen is correct

Recommended test plan:

  1. Run codegen against a real PostGraphile endpoint with reactQuery: { enabled: false }
  2. Verify generated query files have fetchXxxQuery but no useXxxQuery or React Query imports
  3. Verify no mutation files are generated
  4. Run codegen with reactQuery: { enabled: true } and verify hooks are generated
  5. Ensure generated TypeScript compiles without errors in both cases

Notes

Link to Devin run: https://app.devin.ai/sessions/87a0177b0e6a4c6cbd85f27e62e732df
Requested by: Dan Lynch (@pyramation)

- Add reactQuery.enabled config option (default: false)
- Update queries.ts to conditionally generate React Query hooks
- Update mutations.ts to skip generation when React Query disabled
- Update custom-queries.ts to conditionally generate hooks
- Update custom-mutations.ts to skip generation when disabled
- Add comprehensive tests for React Query optional flag
- Fix README: update package name to @constructive-io/graphql-codegen
- Add header/image to README to match other packages in repo

When reactQuery.enabled is false:
- Query generators skip useQuery hooks and React Query imports
- Mutation generators return null (mutations require React Query)
- Standalone fetch functions are still generated for queries
@devin-ai-integration
Copy link
Contributor

🤖 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

@pyramation pyramation merged commit 834ae6a into main Jan 7, 2026
36 checks passed
@pyramation pyramation deleted the devin/1767752540-react-query-optional branch January 7, 2026 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants