You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there an existing issue that is already proposing this?
I have searched the existing issues
Is your feature request related to a problem? Please describe it
If I have a User database entity, a User GQL schema object, and perhaps even some more User interfaces, it's easy to mistake one with another.
When a file relies on both (e.g. a user resolver that fetches User db entity in order to resolve with a User GQL schema object), import aliases need to be used such as Import { User as UserSchema } from '...', which often need to be written manually by the developer, and are prone to typos and lack of consistency in the codebase.
Describe the solution you'd like
Could we make the generated type names configurable? For example, we could add a typeName?(name: string): string option to the GraphQLDefinitionsFactory:
constdefinitionsFactory=newGraphQLDefinitionsFactory();definitionsFactory.generate({typePaths: ['./src/**/*.graphql'],path: join(process.cwd(),'src/api/schema.d.ts'),typeName: (name: string)=>`${name}Schema`// new option!});
What is the motivation / use case for changing the behavior?
I like to give a prefix or suffix to all classnames in my repository, e.g.:
suffix all resolvers with *Resolver (something that is suggested by nestjs docs already),
suffix all db entity classes with *Entity
suffix all input/DTOs with *Input or *Dto or *InputDto
suffix all schema objects with *Schema
However, currently I'm using schema-first approach, and thus TS type definitions of GQL schema interfaces are generated automatically, and the generated type names can't be customized.
The text was updated successfully, but these errors were encountered:
I solve this problem with nx libraries. It lets you define the import path for different types of imports.
nx g @nx/nest:lib libs/my-nest-lib --publishable --importPath=@my-workspace/my-nest-lib
Have a look here: https://nx.dev/nx-api/nest
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
If I have a
User
database entity, aUser
GQL schema object, and perhaps even some moreUser
interfaces, it's easy to mistake one with another.When a file relies on both (e.g. a user resolver that fetches User db entity in order to resolve with a User GQL schema object), import aliases need to be used such as
Import { User as UserSchema } from '...'
, which often need to be written manually by the developer, and are prone to typos and lack of consistency in the codebase.Describe the solution you'd like
Could we make the generated type names configurable? For example, we could add a
typeName?(name: string): string
option to theGraphQLDefinitionsFactory
:This would result in following schema be created:
instead of this one:
@kamilmysliwiec I'd be happy to create a PR for this, just let me know if you'd be open to merging it.
Teachability, documentation, adoption, migration strategy
No response
What is the motivation / use case for changing the behavior?
I like to give a prefix or suffix to all classnames in my repository, e.g.:
*Resolver
(something that is suggested by nestjs docs already),*Entity
*Input
or*Dto
or*InputDto
*Schema
However, currently I'm using schema-first approach, and thus TS type definitions of GQL schema interfaces are generated automatically, and the generated type names can't be customized.
The text was updated successfully, but these errors were encountered: