-
Notifications
You must be signed in to change notification settings - Fork 309
Open
Description
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:
- Two-pass generation - Generate minimal types first, then regenerate with schema-aware config
- Schema-only types - Generate just schema structure types separately
- 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
- graphql-kit: https://github.com/jasonkuhrt/graphql-kit
- graphql-schema-path:
/Users/jasonkuhrt/projects/jasonkuhrt/graphql-kit/src/graphql-schema-path - Current domain organization: Allow grouping root fields by custom means #1147
Metadata
Metadata
Assignees
Labels
No labels