feat: @oneOf typed blueprint definitions with SuperCase node type keys#857
Merged
pyramation merged 1 commit intomainfrom Mar 20, 2026
Merged
feat: @oneOf typed blueprint definitions with SuperCase node type keys#857pyramation merged 1 commit intomainfrom
pyramation merged 1 commit intomainfrom
Conversation
- 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)
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:
|
devin-ai-integration bot
pushed a commit
that referenced
this pull request
Mar 20, 2026
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.
5 tasks
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 infrastructure for generating fully-typed GraphQL
@oneOfinput types for blueprint definitions, using SuperCase node type names (e.g.,DataTimestamps,AuthzEntityMembership) as discriminant keys. This enables SDK autocomplete and compile-time validation for blueprint parameters.Three layers of changes:
PostGraphile plugin (
graphile-settings/src/plugins/blueprint-types/): A factory that acceptsNodeTypeRegistryEntry[]and generates a type hierarchy:DataTimestampsParams) derived fromparameter_schemavia JSON Schema → GraphQL conversionBlueprintNodeInput @oneOf— discriminated union of all non-relation node types +shorthand: StringBlueprintRelationInput @oneOf— discriminated union of relation node typesBlueprintTableInputandBlueprintDefinitionInputwrapping typesCodegen (
graphql/codegen/,graphql/query/): DetectsisOneOfonINPUT_OBJECTtypes from introspection and generates TypeScript discriminated unions instead of interfaces:Introspection: Adds
isOneOffield to the schema introspection query and propagates it through the type registry transform pipeline.Note: The plugin is exported but not yet wired into the production schema build — it requires a caller to query
node_type_registryat build time and pass the entries tocreateBlueprintTypesPlugin(). This is a deliberate separation; wiring happens in a follow-up.Review & Testing Checklist for Human
isOneOfintrospection compatibility: The introspection query now requestsisOneOfon all types. Confirm your GraphQL server (PostGraphile v5 / graphql-js version) supports this field — if not, introspection queries may fail or return errors for non-__Typefields. Test by running the introspection query against a live endpoint.as GraphQLInputTypecasts inplugin.ts(lines 288, 315, 340, 385-390):build.getTypeByName()returnsGraphQLNamedTypeand we cast toGraphQLInputType. If a type name ever collides with a non-input type, this would cause a runtime error. Verify this is safe given the plugin-controlled naming (*Params,Blueprint*Input).parameter_schemaproperties get a_: Booleanplaceholder field, meaning SDK users would write{ DataId: { _: true } }. Evaluate whether this is the desired DX vs. allowing empty objects.pnpm buildat repo root to confirm all packages compile cleanly with the newisOneOfadditions acrossgraphql/query,graphql/codegen, andgraphile/graphile-settings.node_type_registryentries.Notes
BuildLikeinterface injson-schema-to-graphql.tsusesanyforGraphQLNonNull/GraphQLListconstructor params to work around graphql-js type variance. This is intentional — the alternative is duplicating graphql-js's internal generic constraints.isOneOfis added to theResolvedTypeinterface in bothgraphql/queryandgraphql/codegenpackages (they share the same interface shape but are separate files).Link to Devin session: https://app.devin.ai/sessions/5d550def7a314c97854ec12fa09dd4ca
Requested by: @pyramation