Skip to content

Conversation

@yyyyaaa
Copy link
Contributor

@yyyyaaa yyyyaaa commented Jan 4, 2026

Summary

This PR upstreams changes from dashboard/admin package to extract and update graphql codegen and query-builder packages. The @constructive-io/graphql-codegen package has been completely replaced with the new CLI-based GraphQL SDK generator.

Key Changes

  • Build system: Changed from makage to tsup
  • New CLI binary: graphql-codegen with commands: init, generate, generate-orm
  • New features: React Query hooks generation, Prisma-like ORM client generation, watch mode
  • New peer dependencies: @tanstack/react-query, react
  • Workspace dependency: Uses gql-ast workspace package

Updates Since Last Revision

  • Fixed bin entry point to match pgpm/cnc pattern using publishConfig.directory
  • Added publishConfig.directory: "dist" so npm publishes from dist/ as package root
  • Changed bin from ./dist/cli/index.js to cli/index.js (relative to published dist/ root)
  • Updated all exports paths to be relative to dist/ (removed ./dist/ prefix)
  • Removed files field (not needed with publishConfig.directory)
  • Updated pnpm-lock.yaml to reflect publishConfig.directory change
  • CI passing (34/34 checks)

Review & Testing Checklist for Human

This is a BREAKING CHANGE with significant risk. Please verify:

  • publishConfig.directory pattern: Verify this works correctly with tsup (pgpm/cnc use makage which may handle this differently). Test pnpm pack in graphql/codegen to confirm the tarball structure is correct.
  • gql-ast workspace package: Verify packages/gql-ast has a proper package.json and builds correctly
  • CLI functionality: After building, test node dist/cli/index.js --help and actual commands (init, generate, generate-orm)
  • Build output: Run pnpm -C graphql/codegen build and verify dist/cli/index.js has shebang and is executable
  • Peer dependencies: Verify @tanstack/react-query and react peer deps don't cause issues for existing consumers

Recommended Test Plan

  1. Build the workspace: pnpm install && pnpm -C graphql/codegen build
  2. Test CLI help: node graphql/codegen/dist/cli/index.js --help
  3. Verify package structure: cd graphql/codegen && pnpm pack - check tarball has correct structure with cli/index.js at root
  4. Test against a real PostGraphile endpoint if available
  5. Verify the generated code compiles and works

Notes

  • Testing is still in progress per original PR description
  • The tests in this PR are unit tests for codegen logic (snapshot tests), not CLI-level integration tests like pgpm/cnc use
  • The publishConfig.directory pattern was applied to match pgpm/cnc, but tsup may behave differently than makage at publish time - worth verifying

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


Note

BREAKING: package replaced with new CLI-based GraphQL SDK

  • Replaces prior implementation with a CLI generator producing type-safe React Query hooks and a Prisma-like ORM client for PostGraphile
  • Adds CLI binary graphql-codegen with commands init, generate, generate-orm; extensive new README.md, docs/DEVELOPMENT.md, and runnable examples under examples/
  • Introduces workspace dep gql-ast; adds peer deps @tanstack/react-query, react
  • Configures npm publishing from dist via publishConfig.directory; adds bin entry and wrapper bin/graphql-codegen.js
  • Adds Jest ESM config and snapshot tests for type generation (src/__tests__/codegen/*)
  • Updates .gitignore for build artifacts and generated outputs

Written by Cursor Bugbot for commit b57dda5. This will update automatically on new commits. Configure here.

@yyyyaaa yyyyaaa requested a review from pyramation January 4, 2026 08:34
#!/usr/bin/env node

// This is the CLI entry point that loads the built CLI module
import('../dist/cli/index.js').catch((err) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why reaching into dist?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, while it looks weird at first, this is actually a common convention to use for binary executable, we are just creating a shim executable to point to that file. Example in the wild:
https://github.com/vitejs/vite/blob/main/packages/vite/bin/vite.js#L62

pyramation and others added 12 commits January 4, 2026 13:06
- Remove bin/graphql-codegen.js wrapper script that imported from ../dist/cli/index.js
- Point bin directly to ./dist/cli/index.js (tsup already adds shebang via banner config)
- Remove 'bin' from files array since bin folder is deleted

This aligns with the pattern used by pgpm and cnc CLIs which don't have
runtime code reaching into dist/ folder.
- Add publishConfig.directory = 'dist' so npm publishes from dist/ folder
- Update bin to 'cli/index.js' (relative to published root, no dist/ prefix)
- Update main/module/types to be relative to dist/ (no ./dist/ prefix)
- Update all exports paths to be relative to dist/
- Remove files field (not needed with publishConfig.directory)

This matches the exact pattern used by pgpm and cnc CLIs.
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.

4 participants