Skip to content

feat(graphile-settings): add isPrimaryKey, isForeignKey, description to FieldMeta and introspection#915

Merged
pyramation merged 3 commits intomainfrom
devin/1774611586-introspection-field-description
Mar 27, 2026
Merged

feat(graphile-settings): add isPrimaryKey, isForeignKey, description to FieldMeta and introspection#915
pyramation merged 3 commits intomainfrom
devin/1774611586-introspection-field-description

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

@pyramation pyramation commented Mar 27, 2026

Summary

Enriches the FieldMeta introspection type with three new fields—isPrimaryKey, isForeignKey, and description—so that downstream consumers (notably node-type-registry's deriveInterfaceFromTable) can procedurally determine which columns to skip and derive JSDoc from PG column comments, eliminating hardcoded exclusion lists and override objects.

Changes:

  • types.ts: Added isPrimaryKey, isForeignKey, description to FieldMeta; added description to PgAttribute
  • type-mappings.ts: New BuildFieldMetaOptions interface; buildFieldMeta() accepts optional PK/FK flags and reads attr.description
  • table-meta-builder.ts: Computes PK and FK attribute name sets from uniques/relations and passes them through to buildFieldMeta()
  • graphql-meta-field.ts: Exposes the three new fields on the GraphQL MetaField type
  • Snapshots: Updated across graphile-settings, graphql/server-test, and graphql/test to include the three new fields

Updates since last revision

  • Updated unit test assertion in meta-schema.test.ts to expect isPrimaryKey, isForeignKey, description on buildFieldMeta output
  • Updated snapshot files in three packages (graphile-settings, graphql/server-test, graphql/test) to include the new MetaField fields
  • All 41 CI checks now pass

Review & Testing Checklist for Human

  • Verify Graphile v5 runtime attribute objects actually carry descriptionPgAttribute.description assumes getTagsAndDescription() stores PG column comments on the attribute. Confirm this matches the actual shape of codec attributes at runtime (not just the local TS interface).
  • FK detection logicisReferencee !== false is used to filter outgoing FKs. Verify this matches the existing convention in buildForeignKeyConstraints and correctly excludes incoming references.
  • Snapshot correctness — The graphql/server-test and graphql/test snapshots were updated manually (not by running tests against a live DB). CI passed, but spot-check that description: String (nullable) and isPrimaryKey: Boolean! / isForeignKey: Boolean! (non-null) match expected GraphQL nullability.

Suggested test plan: After merging, run pnpm test in graphile/graphile-settings locally with a DB to confirm runtime field values are populated correctly, especially description on tables that have PG column comments.

Notes

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


Open with Devin

…to FieldMeta

- Add description, isPrimaryKey, isForeignKey fields to FieldMeta interface
- Add description to PgAttribute interface to capture PG column comments
- Add BuildFieldMetaOptions interface and update buildFieldMeta() signature
- Compute PK/FK attribute sets in buildTableMeta and pass to buildFieldMeta
- Expose isPrimaryKey, isForeignKey, description in GraphQL MetaFieldType

This enables procedural type derivation in node-type-registry by using
introspection metadata instead of hardcoded lists and override objects.
@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

devin-ai-integration bot pushed a commit that referenced this pull request Mar 27, 2026
- Add isPrimaryKey, isForeignKey, description to IntrospectionFieldMeta
- Remove primaryKeyConstraints/foreignKeyConstraints from IntrospectionTableMeta
  (PK/FK info now lives on each field via graphile-settings PR #915)
- Remove INTERNAL_COLUMNS hardcoded exclusion set entirely
- Remove overrides parameter from deriveInterfaceFromTable — replaced with
  lightweight typeOverrides for columns needing non-default TS types
- Skip columns procedurally via field.isPrimaryKey || field.isForeignKey
- Derive required/optional from field.isNotNull && !field.hasDefault
- Use field.description (PG column comments) for JSDoc instead of hardcoded docs
- Simplify buildBlueprintField, buildBlueprintPolicy, buildBlueprintIndex call sites
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@pyramation pyramation merged commit 42dca35 into main Mar 27, 2026
43 checks passed
@pyramation pyramation deleted the devin/1774611586-introspection-field-description branch March 27, 2026 20:58
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