Skip to content

feat(graphql): add type-name-option-for-custom-type-naming - #3678

Merged
kamilmysliwiec merged 1 commit into
nestjs:masterfrom
mag123c:feat/custom-type-name-definitions
Oct 1, 2025
Merged

kamilmysliwiec merged 1 commit into
nestjs:masterfrom
mag123c:feat/custom-type-name-definitions

Conversation

@mag123c

@mag123c mag123c commented Aug 15, 2025

Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Currently, when generating TypeScript definitions from GraphQL schema files, all type names are used as-is. This can lead to naming conflicts when you have similar type names across different domains (e.g., User database entity, User GraphQL type, UserDTO).

Issue Number: #3440

What is the new behavior?

Added a typeName option to DefinitionsGeneratorOptions that allows users to transform generated type names using a custom function.

Example usage:

definitionsFactory.generate({
  typePaths: ['./src/**/*.graphql'],
  path: './src/graphql.ts',
  typeName: (name) => `${name}Schema`
})

This will transform:

  • User → UserSchema
  • CreateUserInput → CreateUserInputSchema
  • UserRole → UserRoleSchema

Root types (Query, Mutation, Subscription) remain unchanged as IQuery, IMutation, ISubscription.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This is my first contribution to the NestJS GraphQL project. I've carefully studied the codebase and followed the existing patterns to implement this feature. Open to any feedback for improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants