Add support for descriptions on entities, fields, and relationships#1181
Add support for descriptions on entities, fields, and relationships#1181
Conversation
Issue #305: extract entity, field, derivedFrom and enum descriptions from schema.graphql, plumb them through the public config JSON into Table.field/derivedFromField/table, and apply them as Hasura table comments, column comments and relationship comments via pg_track_tables and pg_create_*_relationship. https://claude.ai/code/session_01P4pVR6WbWLk7yGX9bvqnqk
Adds string descriptions on every supported construct in the e2e_test schema (entity, regular fields, indexed fields, derivedFrom relationship, and a new Account entity) plus a `#` comment to confirm comments are ignored. New e2e test pulls the full introspected schema from Hasura, filters to the user-defined entity types, and snapshots their names and descriptions to lock in end-to-end coverage. https://claude.ai/code/session_01P4pVR6WbWLk7yGX9bvqnqk
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR threads optional ChangesDescription Metadata Threading
Sequence DiagramsequenceDiagram
participant Schema as GraphQL Schema
participant Parser as CLI Parser
participant PublicJSON as Public Config JSON
participant ReScript as ReScript Config
participant Hasura as Hasura API
Schema->>Parser: Read type and field descriptions
Parser->>PublicJSON: Serialize EntityJson/PropertyJson/DerivedFieldJson (with descriptions)
PublicJSON->>ReScript: Public config parsed (description fields accepted)
ReScript->>Hasura: Build trackTableConfig (table comment + column_config)
Hasura->>Hasura: Track tables + set table/column comments
Hasura->>Schema: Expose comments via introspection
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 5/8 reviews remaining, refill in 19 minutes and 7 seconds.Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/e2e-tests/src/e2e/e2e.test.ts (1)
138-233: ⚡ Quick winCover the other description paths this PR adds.
This snapshot proves table/column comments and the
@derivedFromarray relationship, butpackages/envio/src/Hasura.resalso wiresfield.descriptioninto object relationships, and the PR scope includes enum descriptions too. A regression in either path would still pass here. Add one linked-entity field and one described enum to the scenario, then include them in this snapshot as well.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/e2e-tests/src/e2e/e2e.test.ts` around lines 138 - 233, The test "should expose schema descriptions via GraphQL introspection" currently only asserts table/column comments and a `@derivedFrom` relationship; modify the test to also cover an object-relationship field and a described enum added by the PR: update the userTypeNames set and/or include the enum type name so the introspected result includes the enum, add the linked-entity field name (the object relationship wired via field.description in Hasura.res) to the fields mapping in the userTypes construction so it appears in the snapshot, and then update the inline snapshot in this test to include the new relationship field (with its description) and the described enum (with its description and enum values) so both paths are asserted. Ensure you reference the test block by its title and update the userTypes / snapshot construction accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/e2e-tests/src/e2e/e2e.test.ts`:
- Around line 138-233: The test "should expose schema descriptions via GraphQL
introspection" currently only asserts table/column comments and a `@derivedFrom`
relationship; modify the test to also cover an object-relationship field and a
described enum added by the PR: update the userTypeNames set and/or include the
enum type name so the introspected result includes the enum, add the
linked-entity field name (the object relationship wired via field.description in
Hasura.res) to the fields mapping in the userTypes construction so it appears in
the snapshot, and then update the inline snapshot in this test to include the
new relationship field (with its description) and the described enum (with its
description and enum values) so both paths are asserted. Ensure you reference
the test block by its title and update the userTypes / snapshot construction
accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a58e207b-247f-4134-bf27-14669cc3209b
📒 Files selected for processing (12)
packages/cli/src/config_parsing/entity_parsing.rspackages/cli/src/config_parsing/field_types.rspackages/cli/src/config_parsing/public_config_json.rspackages/cli/src/hbs_templating/codegen_templates.rspackages/cli/src/hbs_templating/contract_import_templates.rspackages/e2e-tests/src/e2e/e2e.test.tspackages/envio/src/Config.respackages/envio/src/Hasura.respackages/envio/src/PgStorage.respackages/envio/src/db/Table.resscenarios/e2e_test/schema.graphqlscenarios/test_codegen/test/Config_test.res
Hasura overrides the relationship `comment` we set via
pg_create_array_relationship with hardcoded defaults ("An array
relationship" / "An aggregate relationship") in GraphQL introspection.
Our schema-level description still lands in Hasura's metadata API but
isn't visible to introspection, so the snapshot must capture Hasura's
defaults. Also accounts for the auto-generated `outgoing_aggregate`
sibling that Hasura adds when the related table allows aggregations.
https://claude.ai/code/session_01P4pVR6WbWLk7yGX9bvqnqk
Summary
This PR adds support for GraphQL descriptions on entities, fields, and relationships, enabling them to be exposed through Hasura's GraphQL introspection API. Descriptions are parsed from the schema definition and propagated through the entire configuration pipeline to Hasura.
Key Changes
Schema Parsing: Extended the GraphQL schema parser to extract descriptions from entity types, fields, and enums
descriptionfield toEntity,Field, andGraphQLEnumstructs in the Rust config parserConfiguration Propagation: Updated the configuration system to carry descriptions through all layers
descriptionfields toTable,field, andderivedFromFieldtypes in ReScriptHasura Integration: Enhanced the Hasura table tracking to include descriptions
trackTablesfunction to accepttrackTableConfigobjects containing table descriptions and column descriptionscreateEntityRelationshipto support relationship commentsTest Coverage: Added comprehensive tests
Implementation Details
Option<String>in ReScript andOption<String>in Rust)#) which are ignored, and descriptions (quoted strings) which are preservedhttps://claude.ai/code/session_01P4pVR6WbWLk7yGX9bvqnqk
Summary by CodeRabbit
New Features
Tests