Skip to content

feat: wire BlueprintTypesPlugin into production schema build#858

Merged
pyramation merged 2 commits intomainfrom
devin/1774007061-blueprint-types-wiring
Mar 20, 2026
Merged

feat: wire BlueprintTypesPlugin into production schema build#858
pyramation merged 2 commits intomainfrom
devin/1774007061-blueprint-types-wiring

Conversation

@pyramation
Copy link
Contributor

Summary

Wires the BlueprintTypesPlugin (from PR #857) into all production schema build paths so @oneOf typed blueprint input types are generated from live node_type_registry data at schema build time.

New file: fetch-registry.ts — queries metaschema_public.node_type_registry via a short-lived Pool({ max: 1 }) and returns NodeTypeRegistryEntry[]. Returns [] gracefully if the table doesn't exist (code 42P01) or on any other error.

Wiring changes (4 consumers updated):

  • graphql/server/src/middleware/graphile.ts — production server; buildPreset is now async
  • graphile/graphile-schema/src/build-schema.ts — codegen schema build path
  • graphql/query/src/executor.ts — query executor
  • graphql/explorer/src/server.ts — GraphQL explorer

Each consumer calls fetchNodeTypeRegistry(connectionString) before creating the preset and passes the result to BlueprintTypesPreset(nodeTypes).

This PR also includes the foundation from PR #857 (plugin, codegen @oneOf support, introspection isOneOf, tests).

Review & Testing Checklist for Human

  • Single-flight pattern change in graphile.ts: buildPreset is now async and awaited on line 280, which means the fetchNodeTypeRegistry DB query runs before the creation promise is stored in the in-flight map (creating.set(key, ...)). Two simultaneous cache-miss requests for the same key will both run the registry query before coalescing. Verify this is acceptable (the query is idempotent and the schema is still cached after build).
  • Silent failure in fetch-registry.ts: Any error other than 42P01 (undefined_table) logs a console.warn and returns [], meaning blueprint types silently disappear from the schema. Confirm this fail-open behavior is desired vs. failing the schema build.
  • Pool-per-call overhead: fetchNodeTypeRegistry creates and tears down a new Pool({ max: 1 }) on every invocation. In production this only happens on cache misses, but verify this is acceptable vs. reusing an existing pool/connection.
  • Indentation in graphile.ts lines 140–196: The returned object literal inside buildPreset has inconsistent indentation after the refactor to async. Cosmetic, but worth a quick look.
  • End-to-end test plan: After merging both PRs (feat: @oneOf typed blueprint definitions with SuperCase node type keys #857 + this), run pnpm codegen against a database with node_type_registry populated. Verify the generated SDK types include BlueprintNodeInput as a discriminated union with SuperCase node type names as keys. Verify autocomplete works in an IDE.

Notes

  • This PR merges the devin/1774002241-blueprint-typed-sdk branch (PR feat: @oneOf typed blueprint definitions with SuperCase node type keys #857) into a new branch off main. The net-new changes in this PR are: fetch-registry.ts and the 4 consumer wiring files.
  • The graphql/test helper (graphile-test.ts) was intentionally not wired — tests that need blueprint types can pass BlueprintTypesPreset(nodeTypes) via the existing userPreset.extends mechanism.

Link to Devin session: https://app.devin.ai/sessions/5d550def7a314c97854ec12fa09dd4ca
Requested by: @pyramation

- PostGraphile plugin (blueprint-types): reads node_type_registry entries and
  generates @OneOf typed GraphQL input types using SuperCase names as
  discriminant keys (BlueprintNodeInput, BlueprintRelationInput, etc.)
- JSON Schema to GraphQL converter: translates parameter_schema from
  node_type_registry into typed GraphQL input fields
- Codegen: detects isOneOf on INPUT_OBJECT types and generates TypeScript
  discriminated union types instead of interfaces
- Introspection: adds isOneOf field to schema introspection query
- Tests: 12 plugin unit tests + 7 codegen tests (including @OneOf snapshot)
Query node_type_registry at schema build time and pass entries to
BlueprintTypesPreset so @OneOf typed blueprint input types with
SuperCase node type names are generated in the live GraphQL schema.

Changes:
- Add fetchNodeTypeRegistry() utility that queries metaschema_public.node_type_registry
  (gracefully returns [] if table doesn't exist yet)
- Wire BlueprintTypesPreset into production server (graphile.ts)
- Wire BlueprintTypesPreset into build-schema (codegen path)
- Wire BlueprintTypesPreset into query executor
- Wire BlueprintTypesPreset into explorer server

Builds on PR #857 which added the plugin, codegen support, and tests.
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit 87def0c into main Mar 20, 2026
44 checks passed
@pyramation pyramation deleted the devin/1774007061-blueprint-types-wiring branch March 20, 2026 12:08
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.

1 participant