refactor(graphql-codegen): use deepmerge for config merging #643
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
Refactors the GraphQL codegen configuration system to use
deepmergeinstead of manual property-by-property merging. This aligns with patterns used elsewhere in the codebase (@pgpmjs/env,@constructive-io/graphql-env,supabase-test).Key changes:
deepmergedependencymergeConfigwith a singledeepmergecallresolveConfigto just return the deepmerge result directlyDEFAULT_CONFIGto be a completeResolvedConfig(includesendpoint: ''andschema: null)include: ['users']replaces['*']rather than merging to['*', 'users']systemExcludefield for tables, queries, and mutations to always exclude certain items (e.g.,['_meta', 'query']for queries) while allowing users to override withsystemExclude: []if neededUpdates since last revision
generateCommand→generateReactQuerygenerateOrmCommand→generateOrmenabledproperty to both ORM and React Query configs, both defaulting tofalseenabled: boolean,output: string,useSharedTypes: booleanresolveConfig: Now just a single deepmerge call with no special ORM handling needed:packages/cli: The main CLI package (@constructive-io/cli) and its tests were updated to use the renamed functionsReview & Testing Checklist for Human
enabledproperties are wired up: The types forconfig.reactQuery.enabledandconfig.orm.enabledwere added, but verify the generation logic actually checks these flags before generating code. The diff shows type changes but the actual conditional logic may need to be added.generateCommand→generateReactQuery,generateOrmCommand→generateOrm) andreactQuery.enableddefaulting tofalseare breaking changes for external consumerssystemExcludebehavior: Test thatqueries.systemExclude: ['_meta', 'query']is applied by default, and that settingexclude: ['myQuery']doesn't remove the system excludesinclude: ['users']in a config correctly replaces the default['*']Recommended test plan:
pnpm testingraphql/codegen(193 tests should pass)queries: { exclude: ['myQuery'] }and verify_metaandqueryare still excluded (viasystemExclude)queries: { systemExclude: [] }to verify system excludes can be disabledreactQuery: { enabled: true }ororm: { enabled: true }produces the expected outputNotes
pnpm-lock.yamldiff is formatting changes only (pnpm version differences), not actual dependency changesnull), withenabled: falseby defaultas ResolvedConfigtype assertion inresolveConfigis used because deepmerge returns a generic typeLink to Devin run: https://app.devin.ai/sessions/74f133230ae248f2a93a26ccf17cec43
Requested by: Dan Lynch (@pyramation)