feat(meta): add scope block to _meta introspection plugin#1396
Merged
Conversation
Surfaces provisioning scope per table in _meta: scope, tier (global/database/entity), keyColumn, entityTable, and source (smartTag|inferred). Reads the @scope smart tag with a database_id column-inference fallback. Includes unit tests + updated snapshots.
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 comment has been minimized.
This comment has been minimized.
Remove all column-name inference from buildScopeMeta. scope, tier, keyColumn (verbatim), and entityTable now come only from the @scope smart tag (scope/scopeTier/scopeKey/scopeEntityTable); untagged tables return null. Throws if the tag is present without a valid scopeTier.
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 a
scopeblock to each table in the graphile_metaquery, exposing the constructive-db provisioning scope so codegen can auto-inject scope keys (databaseId/orgId), group generated clients/CLI/docs by tier, and pick the right RLS/JWT context for seeds. Follows thestorage/searchprecedent (smart tag → builder →Meta*GraphQL type).The
@scopesmart tag is the sole source of truth — no column-name inference. Key columns are named freely by each generator, so guessing them (entity_id/owner_id/${scope}_id) is brittle. Instead the DB emits everything and the plugin reads it verbatim.New GraphQL shape on
MetaTable:Detection (
scope-meta-builders.ts→buildScopeMeta):Changes
types.ts—ScopeMetainterface +ScopeTiertype;scope: ScopeMeta | nullonTableMeta;source: 'smartTag'.scope-meta-builders.ts(new) —buildScopeMeta, tag-only, no inference; throws on a@scopetag missing a validscopeTier.table-meta-builder.ts— wirebuildScopeMetaintobuildTableMeta.graphql-meta-field.ts—MetaScopeobject type + nullablescopefield onMetaTableType.meta-schema.test.tscovers database/global/entity tags (entity uses a freely-named keytenant_refread verbatim), null-when-untagged (even with adatabase_idcolumn present), and the missing-scopeTierthrow. Regenerated downstream introspection/SDL snapshots (graphql/test,graphql/server-test).graphile-metaskill — documents the "DB emits all fields; plugin reads verbatim; never guess columns" contract.Follow-up (separate constructive-db PR)
Emit the tag from
apply_scope_fields.sql:Until that lands,
_meta.scopeisnullfor all tables (the tag isn't emitted yet) — which is the correct, non-brittle default.Link to Devin session: https://app.devin.ai/sessions/819d1e4face6493393be40f35a48af33
Requested by: @pyramation