Skip to content

graphql-codegen-client-preset: support configurable document/fragment variable suffixes #610

Description

The plugin hardcodes "Document" and "FragmentDoc" when generating import identifiers for operations and fragments.

This means if you set documentVariableSuffix: '' in your codegen config (a supported option), the plugin generates mismatched imports - it looks for GetUserDocument but codegen exports GetUser.

The upstream codegen has several options that affect variable names:

  • documentVariablePrefix / documentVariableSuffix
  • fragmentVariablePrefix / fragmentVariableSuffix
  • dedupeOperationSuffix
  • omitOperationSuffix

None of these are currently configurable in the SWC plugin.

I have a PR ready that adds all six options with backwards-compatible defaults.

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