Repository navigation
feat(postgres): add end-to-end PostgreSQL integration test suite and polymorphic controller support - #17
Merged
Conversation
…polymorphic controller support - Add Docker-based PostgreSQL 14 integration test harness on port 5433 with tmpfs - Implement polymorphic MutationController supporting Sequelize (create, update, destroy) and Mongoose - Add Sequelize sort order conversion in QueryController and sorts helper - Bypass MongoDB filter transformation for PostgreSQL models in getPaginationAndFilterParams - Provide client-facing GraphQL SDL input and parser for model & association extraction - Add 118 automated integration tests covering CRUD, 16 filtering operators, pagination, sorting, relationships, DataLoaders, transactions, schema evolution, concurrency, and GraphQL operations
…t-facing GraphQL API layer
… detection for docker compose v2 in setup.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
📌 Pull Request Description
This PR delivers a production-grade, end-to-end PostgreSQL integration test suite for AutoGraphQL. Tests run against a live PostgreSQL 14 instance in an isolated Docker container and are driven directly by client-facing GraphQL SDL.
During implementation, multiple critical runtime defects in core controllers were identified and resolved, enabling full polymorphic dual-database support across MongoDB (Mongoose) and PostgreSQL (Sequelize).
🛠️ Changes Proposed
Polymorphic Mutation Controller:
MutationController.js: Previous CRUD mutations (addDocument,updateDocument,deleteDocument) exclusively invoked Mongoose APIs (new Model().save(),.findOne().exec(),.findOneAndRemove()), crashing withTypeErrorwhen targeting PostgreSQL models.isPgModelbranching to route to Sequelize methods (Model.create(),Model.findOne({ where }),Model.update(),Model.destroy()) while preserving Mongoose behavior.Sequelize Sort Order Translation:
sorts.js: AddedconvertSortToSequelizeOrderandgetSortOrderForSequelizereturning Sequelizeorderformat ([['field', 'ASC']]/[['field', 'DESC']]).QueryController/index.js(getQueriedResultandgetQueriedResultFromLast).Filter Pipeline PostgreSQL Pass-Through:
getPaginationAndFilterParams.js: WhenisPgModelis active, bypasses MongoDB query operator transformation ($and,$or,$gt,$in) so raw GraphQL filter arguments flow cleanly intobuildSequelizeWhereClause().GraphQL SDL-Driven Test Infrastructure:
test/postgres/docker-compose.test.yml: Isolated PostgreSQL 14 Alpine instance mapped to port5433with in-memory tmpfs for high-performance test execution.test/postgres/setup.js: Database lifecycle management, container readiness polling, dynamic model compilation, and table resets between suites.test/postgres/testSchema.js: Single source of truth defined in clean client-facing GraphQL SDL (pgGraphQLSDL), with AST parser extracting model definitions, constraints, defaults, and relations (@relation). Also provides executable GraphQL schema generation with live Sequelize resolvers.Comprehensive Integration Test Suite:
test/postgres/pgIntegration.test.js: 118 automated tests covering 17 categories:_not,_gt,_gte,_lt,_lte,_in,_contains,_startsWith,_endsWith,_exists,AND,OR,NOT)first,skip, non-overlapping pages)alter: truecolumn addition preserving data)Tooling & Scripts:
npm run test:postgresscript topackage.json.🧪 Testing & Verification
npm run test:postgrespasses 100% (118/118 passing in ~3s)npm testpasses with 100% success rate (220/220 passing across entire repository)npm run schema:diff)🛡️ Security & Boundaries