Skip to content

narrow types#570

Merged
nikgraf merged 2 commits intomainfrom
nik/narrow-types
Dec 6, 2025
Merged

narrow types#570
nikgraf merged 2 commits intomainfrom
nik/narrow-types

Conversation

@nikgraf
Copy link
Collaborator

@nikgraf nikgraf commented Dec 6, 2025

Closes #566

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds type filtering to relation queries by extracting and applying target entity type IDs. This enables narrowing query results to only include relations to/from specific entity types, improving query precision and potentially performance.

  • Extracts target type IDs from relation schemas and includes them in relation metadata
  • Adds GraphQL filters to relation queries based on entity types (using toEntity.typeIds for relations and fromEntity.typeIds for backlinks)
  • Refactors tuple type extraction into a reusable helper function

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/hypergraph/test/utils/relation-config-overrides.test.ts Adds test data (Episode/Podcast schemas), helper function for stringifying type IDs, and tests verifying type ID filters are correctly applied to relations and backlinks
packages/hypergraph/src/utils/relation-query-helpers.ts Implements buildRelationTypeIdsFilter to generate GraphQL filter syntax for entity type IDs and integrates it into the relation query builder
packages/hypergraph/src/utils/get-relation-type-ids.ts Adds getRelationTupleType and getRelationTargetTypeIds helpers to extract type information from schema AST, and includes targetTypeIds in relation metadata throughout the extraction logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nikgraf nikgraf merged commit 3f8c22d into main Dec 6, 2025
6 checks passed
@nikgraf nikgraf deleted the nik/narrow-types branch December 6, 2025 19:25
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.

Tighten relations querying

2 participants