From b2ee26105ed7a24879a8ebec369299b085f45a88 Mon Sep 17 00:00:00 2001 From: ghou9khub Date: Wed, 7 Jan 2026 22:18:06 -0800 Subject: [PATCH 01/12] Added codegen db flow --- packages/cli/README.md | 59 +++++---------- packages/cli/__tests__/cli.test.ts | 3 + packages/cli/__tests__/codegen.test.ts | 75 ++++++++++--------- packages/cli/package.json | 9 +++ packages/cli/src/commands.ts | 2 +- packages/cli/src/commands/codegen.ts | 99 ++++++++++++++++++++++---- pnpm-lock.yaml | 27 +++++++ 7 files changed, 182 insertions(+), 92 deletions(-) diff --git a/packages/cli/README.md b/packages/cli/README.md index 540044920..53e979035 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -58,55 +58,30 @@ cnc explorer --origin http://localhost:3000 ### `cnc codegen` -Generate TypeScript types, operations, and SDK from a GraphQL schema. +Generate TypeScript types, operations, and SDK from a PostGraphile API. ```bash -# From SDL file -cnc codegen --schema ./schema.graphql --out ./codegen +# From endpoint +cnc codegen --endpoint http://localhost:5555/graphql --out ./codegen -# From endpoint with Host override -cnc codegen --endpoint http://localhost:3000/graphql --headerHost meta8.localhost --out ./codegen +# From database (spins a temporary PostGraphile server, introspects, generates, then tears down) +cnc codegen --database constructive_db --schemas public --pgHost localhost --pgPort 5432 --pgUser postgres --pgPassword password --out ./codegen --verbose ``` **Options:** -- `--schema ` - Schema SDL file path -- `--endpoint ` - GraphQL endpoint to fetch schema via introspection -- `--headerHost ` - Optional Host header for endpoint requests -- `--auth ` - Optional Authorization header value -- `--header "Name: Value"` - Optional HTTP header (repeatable) -- `--out ` - Output root directory (default: graphql/codegen/dist) -- `--format ` - Document format (default: gql) -- `--convention