feat(graphile-schema): add buildIntrospectionJSON() for database metadata export#912
Merged
pyramation merged 1 commit intomainfrom Mar 27, 2026
Merged
Conversation
…data export Adds a new buildIntrospectionJSON() function to graphile-schema that returns the full TableMeta[] array collected by MetaSchemaPlugin during schema build. This enables downstream consumers (like constructive-db's generate:schemas pipeline) to export structured introspection JSON alongside the .graphql SDL files. Also exports the TableMeta, FieldMeta, TypeMeta, IndexMeta, and related types from both graphile-settings and graphile-schema so consumers get full type safety.
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:
|
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
buildIntrospectionJSON()tographile-schema— a thin wrapper aroundbuildSchemaSDL()that returns theTableMeta[]array populated byMetaSchemaPluginduring the schema build. This enables downstream consumers (e.g.constructive-db'sgenerate:schemaspipeline) to export structured introspection JSON alongside.graphqlSDL files, which can then drive blueprint type codegen instead of hand-coding structural types.Changes:
graphile-schema/src/build-introspection.ts—buildIntrospectionJSON(opts)callsbuildSchemaSDL, then returns a shallow copy of_cachedTablesMetagraphile-settings/src/plugins/index.ts— re-exports all 14 meta-schema types (TableMeta,FieldMeta,TypeMeta, etc.)graphile-schema/src/index.ts— re-exportsbuildIntrospectionJSON+ all meta-schema types fromgraphile-settingsReview & Testing Checklist for Human
buildIntrospectionJSONdepends onbuildSchemaSDLpopulating the module-level_cachedTablesMetaas a side-effect. Verify this is acceptable for your use case (concurrent calls would clobber the shared cache). Only a shallow copy is returned — mutations to nested objects would affect the cache.meta-schema/types.tsthat downstream consumers need are included in the 14 re-exported types. If the types file has additional exports (sub-types ofQueryMeta, etc.), they may need to be added later.buildIntrospectionJSON. Consider whether a test (even a smoke test verifying the function returns a non-empty array against a test database) should be added before or after merge.Notes
constructive-dbwill callbuildIntrospectionJSON()ingenerate-schemas.tsand write the result tointrospection.json, whichgenerate-types.tswill then consume to derive blueprint structural types.BuildIntrospectionOptionsis a type alias for the existingBuildSchemaOptions— introduced for API clarity so callers don't need to know the SDL function is involved.Link to Devin session: https://app.devin.ai/sessions/ce1b2dafd42341bea5d7793b0c05ba6c
Requested by: @pyramation