Skip to content

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Jan 22, 2026

Summary

Refactors the GraphQL codegen configuration system to use deepmerge instead 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:

  • Added deepmerge dependency
  • Replaced ~80 lines of manual merge logic in mergeConfig with a single deepmerge call
  • Simplified resolveConfig to just return the deepmerge result directly
  • Updated DEFAULT_CONFIG to be a complete ResolvedConfig (includes endpoint: '' and schema: null)
  • Uses array replacement strategy (source wins) to ensure include: ['users'] replaces ['*'] rather than merging to ['*', 'users']
  • Added systemExclude field for tables, queries, and mutations to always exclude certain items (e.g., ['_meta', 'query'] for queries) while allowing users to override with systemExclude: [] if needed

Updates since last revision

  • Renamed command functions for clarity:
    • generateCommandgenerateReactQuery
    • generateOrmCommandgenerateOrm
  • Added enabled property to both ORM and React Query configs, both defaulting to false
  • Simplified ORM handling: ORM config is no longer nullable - it's always an object with enabled: boolean, output: string, useSharedTypes: boolean
  • Simplified resolveConfig: Now just a single deepmerge call with no special ORM handling needed:
    return deepmerge(DEFAULT_CONFIG, config, { arrayMerge: replaceArrays }) as ResolvedConfig;
  • Updated packages/cli: The main CLI package (@constructive-io/cli) and its tests were updated to use the renamed functions

Review & Testing Checklist for Human

  • IMPORTANT: Verify enabled properties are wired up: The types for config.reactQuery.enabled and config.orm.enabled were 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.
  • Breaking change awareness: The function renames (generateCommandgenerateReactQuery, generateOrmCommandgenerateOrm) and reactQuery.enabled defaulting to false are breaking changes for external consumers
  • Verify systemExclude behavior: Test that queries.systemExclude: ['_meta', 'query'] is applied by default, and that setting exclude: ['myQuery'] doesn't remove the system excludes
  • Verify array replacement behavior: Test that specifying include: ['users'] in a config correctly replaces the default ['*']

Recommended test plan:

  1. Run pnpm test in graphql/codegen (193 tests should pass)
  2. Try generating code with a config that sets queries: { exclude: ['myQuery'] } and verify _meta and query are still excluded (via systemExclude)
  3. Test with queries: { systemExclude: [] } to verify system excludes can be disabled
  4. Verify that setting reactQuery: { enabled: true } or orm: { enabled: true } produces the expected output

Notes

  • The large pnpm-lock.yaml diff is formatting changes only (pnpm version differences), not actual dependency changes
  • ORM config is now always an object (never null), with enabled: false by default
  • The as ResolvedConfig type assertion in resolveConfig is used because deepmerge returns a generic type

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

- Add deepmerge dependency to graphql-codegen package
- Refactor mergeConfig to use deepmerge with array replacement strategy
- Refactor resolveConfig to use deepmerge for applying defaults
- Array replacement ensures user-provided arrays like include: ['users']
  replace defaults like ['*'] rather than merging to ['*', 'users']
- Aligns with patterns used in @pgpmjs/env and @constructive-io/graphql-env
@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

… result directly

- Add endpoint and schema to DEFAULT_CONFIG with default values
- Remove manual property plucking after deepmerge
- Keep ORM special handling (null by default, merge with defaults when provided)
…nfig

- Add systemExclude field to tables, queries, and mutations filter configs
- Move default ['_meta', 'query'] from queries.exclude to queries.systemExclude
- Users can override systemExclude: [] to disable system excludes
- Clean up resolveConfig to use deepmerge customMerge for ORM handling
- Update filtering logic to combine exclude and systemExclude arrays
Remove customMerge complexity - just deepmerge then handle ORM separately if provided
- Rename generateCommand to generateReactQuery
- Rename generateOrmCommand to generateOrm
- Add enabled property to ORM config (default false)
- Change reactQuery.enabled default to false
- Simplify resolveConfig (ORM is no longer nullable)
- Update all imports and usages
@pyramation pyramation merged commit 0f640c2 into main Jan 22, 2026
48 checks passed
@pyramation pyramation deleted the devin/1769063375-codegen-deepmerge-refactor branch January 22, 2026 10:47
@mohamedbouddi7777-dev
Copy link

يحاول ان اتفهم يعني سهل الاعمال لان عندي عمل كثيره لا اقدر ان اشتغل على كل شيء يعني سهل الامور اريد الاداره

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.

3 participants