Skip to content

feat: Schema-aware type-safe configuration using graphql-kit/graphql-schema-path #1408

@jasonkuhrt

Description

@jasonkuhrt

Overview

Enable schema-aware, type-safe configuration for generator features like domain-based method organization.

Problem

Currently, generator configuration uses plain strings and RegExp patterns without schema awareness:

// Current: No type safety or schema validation
methodsOrganization: {
  domains: {
    rules: [
      { pattern: /^pokemonBy/, groupName: 'pokemon', methodName: 'getOne' }
    ]
  }
}

This has limitations:

  • No autocomplete for field names
  • No compile-time validation
  • Typos only discovered at generation time
  • No IDE navigation to field definitions

Solution

Use graphql-kit/graphql-schema-path for type-safe schema paths:

// Future: Type-safe with schema awareness
methodsOrganization: {
  domains: {
    rules: [
      { 
        pattern: SchemaPath.parse('Query.pokemonByName'),  // ✅ Type-safe!
        groupName: 'pokemon', 
        methodName: 'getOne' 
      }
    ]
  }
}

Challenges

Circular Dependency:

  • Config file generates types
  • Config file would need generated types for schema awareness
  • Chicken-egg problem!

Possible Approaches:

  1. Two-pass generation - Generate minimal types first, then regenerate with schema-aware config
  2. Schema-only types - Generate just schema structure types separately
  3. Implementation validation only - Keep config simple, use graphql-schema-path in generator for better error messages

Benefits

  • Better DX with autocomplete and type safety
  • Earlier error detection (at config time vs generation time)
  • IDE integration (jump to field definitions)
  • Validation that field patterns match actual schema

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions