test(server-test): add CLI e2e tests against real PostgreSQL database#916
Open
pyramation wants to merge 1 commit intomainfrom
Open
test(server-test): add CLI e2e tests against real PostgreSQL database#916pyramation wants to merge 1 commit intomainfrom
pyramation wants to merge 1 commit intomainfrom
Conversation
Tests generated CLI commands (codegen → transpile → execute) against a running PostgreSQL database with a real GraphQL server. - Uses ts.transpileModule to strip types without resolving imports - Uses async spawn (not execFileSync) to keep event loop unblocked - Sets up appstash context pointing at test server endpoint - Resolves NODE_PATH for pnpm's strict module isolation 5 focused corner-case tests: 1. Paginated list with --where (dot-notation) + --fields 2. Cursor-based forward pagination (--after) 3. find-first with --where.name.equalTo 4. Combined --where + --orderBy + --fields 5. Empty result set handling
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Summary
Adds 5 end-to-end tests that exercise the full CLI pipeline: codegen → transpile → execute as child process against a running PostgreSQL database with a real GraphQL server.
Approach (Approach A):
getConnections()spins up a real Postgres DB + GraphQL HTTP servergenerateCli()andgenerateOrm()produce TypeScript source filests.transpileModulestrips types without resolving imports (avoids needing all type packages in a temp dir)$HOMEpointing at the test server endpointspawn, notexecFileSync) runs the compiled CLI against the live serverWhy
spawninstead ofexecFileSync: The GraphQL server runs in the same Node.js process. Synchronous child execution blocks the event loop, preventing the server from responding — causing a deadlock/timeout.5 focused corner-case tests:
--where(dot-notation) +--fieldsprojection--limit+--after)find-firstwith--where.name.equalTo--where+--orderBy+--fieldsPackage.json changes: Added
@0no-co/graphql.web,gql-ast,appstash,inquirerer, andnested-objas devDependencies inserver-test— these are ORM/CLI runtime deps needed by the child process.Review & Testing Checklist for Human
buildAnimalsTable()object (lines 100–205): This manually mirrors the simple-seed animals schema. Verify the field names, types, inflection keys (especiallyorderByType: 'AnimalOrderBy'), and query names match what introspection actually produces. If the codegen's expected Table shape evolves, this will silently generate wrong code.raw.data?.animals ?? raw): Tests assume the CLI prints the raw ORMexecute()result as JSON. Verify this matches the actualhandleList/handleFindFirstoutput format. The fallback chain could mask shape mismatches.node.id === 'a0000001-0000-0000-0000-000000000001'— tied tosimple-seed/test-data.sql. Confirm this ID exists and won't change.resolveNodePaths()pnpm discovery: Walksrequire.resolve()paths to find all intermediatenode_modulesdirs for pnpm strict isolation. Verify this works in CI (which may have a different pnpm version or hoisting config).Recommended test plan: Run
cd graphql/server-test && pnpm test -- --testPathPattern cli-e2e --verboselocally and in CI to confirm all 5 tests pass. Also verify the existing test suite still passes (pnpm test).Notes
pnpm-lock.yamldiff is large but is purely formatting changes (single-line vs multi-line resolution objects) from a lockfile refresh — no dependency version changes.graphile-cacheERROR log during teardown (PostGraphile instance has been released) is pre-existing in other server-test suites and is harmless.Link to Devin session: https://app.devin.ai/sessions/c92c3a11450342f8875625a60fa1be28
Requested by: @pyramation