feat(graphql-codegen): make React Query optional with config flag #570
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
Adds a
reactQuery.enabledconfiguration 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:
reactQuery.enabledconfig option (defaults tofalse)useQueryhooks and React Query imports when disablednullwhen disabled (mutations require React Query)fetchXxxQueryfunctions are always generated regardless of setting@constructive-io/graphql-sdk→@constructive-io/graphql-codegen) and added header/badges to match other packagesReview & Testing Checklist for Human
reactQuery.enabled: falseas the default is intentional. Existing users upgrading will no longer get React Query hooks unless they explicitly setreactQuery: { enabled: true }in their config.reactQuery.enabled: trueandreactQuery.enabled: falseto ensure generated code compiles and works correctly@constructive-io/graphql-sdkto@constructive-io/graphql-codegenis correctRecommended test plan:
reactQuery: { enabled: false }fetchXxxQuerybut nouseXxxQueryor React Query importsreactQuery: { enabled: true }and verify hooks are generatedNotes
Link to Devin run: https://app.devin.ai/sessions/87a0177b0e6a4c6cbd85f27e62e732df
Requested by: Dan Lynch (@pyramation)