Skip to content

Conversation

mag123c
Copy link
Contributor

@mag123c mag123c commented Aug 15, 2025

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.

@mag123c mag123c force-pushed the feat/custom-type-name-definitions branch from 350e11d to 9e151cd Compare August 15, 2025 14:21
@kamilmysliwiec kamilmysliwiec merged commit a1ccdaf into nestjs:master Oct 1, 2025
1 check passed
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