Skip to content

Enhance Type Relationship Tracking #61

@carloseberhardt

Description

@carloseberhardt

Problem

We track basic type relationships but could be more comprehensive. The current TypeRelationship interface is quite basic and doesn't capture the full richness of GraphQL type relationships.

Current Implementation

export interface TypeRelationship {
  fromType: string;
  toType: string;
  fieldName: string;
  isList: boolean;
}

This only captures field-to-type relationships, missing:

  • Interface implementations
  • Union memberships
  • Directive applications
  • Inheritance hierarchies
  • Input/output type relationships

Enhanced Relationship Types

1. Interface Implementation

{
  type: "implements",
  implementer: "Product",
  interface: "Node",
  location: {...}
}

2. Union Membership

{
  type: "union_member",
  union: "SearchResult", 
  member: "Product",
  location: {...}
}

3. Directive Application

{
  type: "directive",
  target: "Product.price",
  directive: "materializer",
  arguments: {...},
  location: {...}
}

4. Input/Output Relationships

{
  type: "input_output",
  operation: "createProduct",
  input: "ProductInput",
  output: "Product",
  location: {...}
}

Benefits

  • Better Visualization: Schema visualizer can show richer relationships
  • Enhanced Navigation: Go-to-definition for interfaces, unions, etc.
  • Impact Analysis: Understand what's affected by type changes
  • Documentation: Auto-generate relationship documentation
  • Validation: Detect broken relationships

Implementation Approach

  1. Extend TypeRelationship: Add discriminated union for different relationship types
  2. Enhanced Indexing: Capture more relationship types during schema parsing
  3. Backward Compatibility: Maintain existing field relationships
  4. Visualization Updates: Update schema visualizer to show new relationships
  5. API Extensions: Add methods to query specific relationship types

Acceptance Criteria

  • Track interface implementations
  • Track union memberships
  • Track directive applications
  • Track input/output relationships
  • Maintain backward compatibility
  • Update schema visualizer to show enhanced relationships
  • Add query methods for specific relationship types
  • Performance impact is minimal

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions