Skip to content

feat!: Move knex-specific loader methods to knexLoader#407

Open
wschurman wants to merge 1 commit intomainfrom
wschurman/01-30-feat_move_knex-specific_loader_methods_to_knexloader
Open

feat!: Move knex-specific loader methods to knexLoader#407
wschurman wants to merge 1 commit intomainfrom
wschurman/01-30-feat_move_knex-specific_loader_methods_to_knexloader

Conversation

@wschurman
Copy link
Member

@wschurman wschurman commented Jan 30, 2026

Why

This is a long stack, but the goal is to make a place to put postgres-specific loading logic to avoid polluting the core dataloader-based library with logic specific to knex/postgres. And potentially even postgres-specific mutation logic but that's way down the road.

The best place for this stuff is in the entity-database-adapter-knex library. Therefore, the strategy is (in PR order):

  1. Move existing knex/postgres-specific loader methods to a new loader, knexLoader. I'm also open to calling this a "Postgres Loader" since the entity-database-adapter-knex package already uses postgres-specific queries (and more are added here since this stack eventually produces raw queries) within knex even though technically knex is database agnostic.
  2. Move knex-specific logic out of EntityDataManager, move it to its own EntityKnexDataManager.
  3. Move these two now-separated pieces into the entity-database-adapter-knex package. This requires creating a "plugin" system for database adapters, where when they are included their methods are added to the prototype so that seamless loading continues to work.
  4. Add a codemod for these three pieces.
  5. Add the first new feature to entity loading, load by tagged template string, which creates a better/safer way to express raw queries for loading entities.

Future other things that could be added here (after thorough thought on authorization) are:

  • Pagination
  • Create, update, delete by tagged template string
  • Batch creation
  • Upsert (maybe)

For Reviewers

The most critical things to assess are:

How

This is part 1. It refactors the loaders by moving loadManyByFieldEqualityConjunctionAsync, loadFirstByFieldEqualityConjunctionAsync, and loadManyByRawWhereClauseAsync to a separate loader.

The new pattern for these is:

await PostgresTestEntity.knexLoader(vc1).loadManyByRawWhereClauseAsync(...)

Test Plan

This has full coverage in new tests.

Copy link
Member Author

wschurman commented Jan 30, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@wschurman wschurman force-pushed the wschurman/01-30-feat_move_knex-specific_loader_methods_to_knexloader branch from 78b4db1 to 8efee7b Compare January 30, 2026 18:40
@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7b6ff09) to head (a0423c5).

Additional details and impacted files
@@            Coverage Diff             @@
##              main      #407    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           91        96     +5     
  Lines        12694     13144   +450     
  Branches      1122      1140    +18     
==========================================
+ Hits         12694     13144   +450     
Flag Coverage Δ
integration 6.98% <0.00%> (-0.25%) ⬇️
unittest 97.18% <100.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wschurman wschurman force-pushed the wschurman/01-30-feat_move_knex-specific_loader_methods_to_knexloader branch from fd886c7 to a0423c5 Compare February 4, 2026 21:29
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.

1 participant