Skip to content

Generated enum type names can contain $ (invalid GraphQL grammar) via the $typeName convention #344

Description

@izumin5210

Summary

The $typeName discriminator convention can leak a literal $ into auto-generated GraphQL type names, producing schema files that are not valid GraphQL.

Evidence

The committed goldens of union-dollar-typename-basic and union-typename-priority (packages/cli/src/gen-orchestrator/testdata/) emit:

enum SearchQuery$typeNameInput { ... }

$ is not a valid character in GraphQL names, so the committed schema.graphql is unparseable by graphql-js (parse() throws).

Origin

Auto-type naming builds generated names from field paths; when the field is the $typeName discriminator itself, the $ passes through unsanitized into the type name.

Expected

Either sanitize/exclude the discriminator field from auto-type naming, or reject the situation with a diagnostic — emitting syntactically invalid SDL should never happen.

Context

Discovered during the refactoring plan's Phase 6 pruning survey (.kiro/specs/refactor-plan.md, Phase 6 execution note), where parsing the generated SDL crashed on these cases. Deliberately not fixed in that PR (out of scope).

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions