Describe the bug
The schema fails to be generated when using an EnumType
To Reproduce
export enum UserRole {
ADMIN = "ADMIN",
EDITOR = "EDITOR",
GHOST = "GHOST"
}
registerEnumType(UserRole, {
name: "User Role",
description: "User role types"
});
@Entity("users")
@ObjectType()
export class User extends BaseEntity {
@Field((type) => UserRole, {
description: "User's role (share role options)"
})
@Column({
type: "enum",
enum: UserRole,
default: UserRole.GHOST
})
role: UserRole;
}
When I comment the part that sets the field type to that of the enum (as shown below) it runs fine.
// @Field((type) => UserRole, {
// description: "User's role (share role options)"
// })
@Column({
type: "enum",
enum: UserRole,
default: UserRole.GHOST
})
role: UserRole;
Also, if I swap UserRole to a String type it works fine.
@Field((type) => String, {
description: "User's role (share role options)"
})
Expected behavior
The schema should be generated.
Logs
(node:51343) UnhandledPromiseRejectionWarning: Error: Generating schema error
at Function.
at Generator.next (
at fulfilled (/project-path/node_modules/tslib/tslib.js:110:62)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:51343) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:51343) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[nodemon] clean exit - waiting for changes before restart
Enviorment (please complete the following information):
Additional context
Add any other context about the problem here.
1) Fill the template properly because latest is not precise at all.
2) Capture the error and print the details property of that GeneratingSchemaError.
registerEnumType(UserRole, {
name: "User Role",
description: "User role types"
});
Thinking the space in "User Role" is a problem.
@wickning1
That's solved it actually. Thanks so much.
Can't believe I missed that.
Thanks again!
Most helpful comment
Thinking the space in "User Role" is a problem.