Skip to content

feat(graphile-schema): add buildIntrospectionJSON() for database metadata export#912

Merged
pyramation merged 1 commit intomainfrom
devin/1774572350-introspection-json-export
Mar 27, 2026
Merged

feat(graphile-schema): add buildIntrospectionJSON() for database metadata export#912
pyramation merged 1 commit intomainfrom
devin/1774572350-introspection-json-export

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

Summary

Adds buildIntrospectionJSON() to graphile-schema — a thin wrapper around buildSchemaSDL() that returns the TableMeta[] array populated by MetaSchemaPlugin during the schema build. This enables downstream consumers (e.g. constructive-db's generate:schemas pipeline) to export structured introspection JSON alongside .graphql SDL files, which can then drive blueprint type codegen instead of hand-coding structural types.

Changes:

  • New file graphile-schema/src/build-introspection.tsbuildIntrospectionJSON(opts) calls buildSchemaSDL, then returns a shallow copy of _cachedTablesMeta
  • graphile-settings/src/plugins/index.ts — re-exports all 14 meta-schema types (TableMeta, FieldMeta, TypeMeta, etc.)
  • graphile-schema/src/index.ts — re-exports buildIntrospectionJSON + all meta-schema types from graphile-settings

Review & Testing Checklist for Human

  • Side-effect reliance: buildIntrospectionJSON depends on buildSchemaSDL populating the module-level _cachedTablesMeta as 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.
  • Type completeness: Confirm all types from meta-schema/types.ts that downstream consumers need are included in the 14 re-exported types. If the types file has additional exports (sub-types of QueryMeta, etc.), they may need to be added later.
  • No tests included: This PR has no unit tests for 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

  • This is the first half of a two-repo effort. The follow-up PR on constructive-db will call buildIntrospectionJSON() in generate-schemas.ts and write the result to introspection.json, which generate-types.ts will then consume to derive blueprint structural types.
  • BuildIntrospectionOptions is a type alias for the existing BuildSchemaOptions — 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

…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.
@devin-ai-integration
Copy link
Copy Markdown
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 449785a into main Mar 27, 2026
43 checks passed
@pyramation pyramation deleted the devin/1774572350-introspection-json-export branch March 27, 2026 01:40
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