refactor(export): add @pgpmjs/migrate-client workspace package for typed sql_actions fetching#823
Open
pyramation wants to merge 3 commits intofeature/pgpm-export-graphqlfrom
Open
Conversation
…ions fetching Replace the hand-rolled GraphQLClient usage for sql_actions with the typed ORM client from @constructive-db/migrate-client: - Type-safe query building (no manual field strings) - Type-safe filtering (no string condition building) - Proper cursor-based pagination via ORM's findMany() - Uses ORM's FetchAdapter instead of custom HTTP client for migrate endpoint The GraphQLClient is still used for meta/services endpoint fetching (export-graphql-meta.ts and CLI), since those use a different API schema.
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:
|
…grate-client - Create pgpm/migrate-client/ as a workspace package (no cross-repo npm dep) - Copy migrate.graphql schema + generated ORM from constructive-db - Add codegen generate script for future regeneration - Update pgpm/core to use workspace:^ dependency - Update import from @constructive-db/migrate-client to @pgpmjs/migrate-client
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.
refactor(export): add @pgpmjs/migrate-client workspace package for typed sql_actions fetching
Summary
Replaces the hand-rolled
GraphQLClientusage for fetchingsql_actionsfrom the migrate endpoint with a new workspace package (@pgpmjs/migrate-client) that provides a typed ORM client generated from themigrate.graphqlschema.Before: Manual field strings + untyped
fetchAllNodes('sqlActions', 'id\ndatabaseId\n...', { databaseId })After: Typed
migrateDb.sqlAction.findMany({ select: { id: true, ... }, where: { databaseId: { equalTo: databaseId } } })Architecture
sdk/migrate-client/— new workspace package containing themigrate.graphqlschema and generated ORM code (SqlActionModel,MigrateFileModel,executeSql,runMigration)@constructive-io/graphql-codegenis a devDependency only (used forpnpm generateregeneration)gql-ast,@0no-co/graphql.web,@constructive-io/graphql-typespgpm/coredepends on it viaworkspace:^— no cross-repo npm publish requiredThe
GraphQLClientandgraphql-naming.tsare not deleted — they're still used byexport-graphql-meta.ts(meta/services endpoint) and the CLI's database/schema fetching, which use a different GraphQL API schema.Updates since last revision
@constructive-db/migrate-clientfrom constructive-db#586 which would need to be published to npm. Now@pgpmjs/migrate-clientlives insdk/migrate-client/as a workspace dep — no publishing step needed.pgpm/tosdk/directory to match the convention of other SDK packages (constructive-sdk,constructive-cli,constructive-react).pnpm generatescript is included for future regeneration from the schema file.Review & Testing Checklist for Human
pnpm generatescript insdk/migrate-clientrequiresgraphile-connection-filter(transitive dep of codegen) which wasn't available in the build environment. The committed ORM files were copied from constructive-db's existing generated output. Verify thatpnpm generateworks in a fully-configured environment, or that the copied output matches what local codegen would produce.condition→wherebehavioral change: The old code passedcondition: { databaseId }(PostGraphile exact-match condition arg). The new code useswhere: { databaseId: { equalTo: databaseId } }(PostGraphile filter arg). These should be functionally equivalent for UUID equality, but verify against a live migrate API that the same rows are returned.GraphQLClient.query()had 3 retries with exponential backoff for transient network errors (ECONNRESET,ECONNREFUSED, etc.). The ORM'sFetchAdapterdoes not retry. Decide whether this is acceptable or whether a retry wrapper should be added.first: 100+afterCursorin a while loop. The old code usedfetchAllNodeswhich abstracted pagination. Verify that the manual loop terminates correctly and returns identical results.sdk/migrate-client/schemas/migrate.graphqlis a static copy from constructive-db. If the upstreamdb_migrateschema changes, this file must be manually re-copied andpnpm generatere-run.feature/pgpm-export-graphql). Build was verified locally only. Recommend runningpgpm export --graphql-endpoint <private-api> --migrate-endpoint <migrate-api>against a live Constructive instance to verifysql_actionsare fetched and written correctly.Notes