Skip to main content

Emit ID fields with type

By default, TypeGraphQL Prisma generator emits GraphQL types for fields with the underlying data types, like Int or String scalars.

However, in some cases like when using GraphQL Relay, you may want to emit the ID GraphQL scalar type for those fields. To accomplish this, use the emitIdAsIDType generator option:

generator typegraphql {
provider = "typegraphql-prisma"
emitIdAsIDType = true
}

It will generate then the id fields using the TypeGraphQL.ID GraphQL scalar, e.g.:

@TypeGraphQL.ObjectType("Post", {})
export class Post {
@TypeGraphQL.Field(_type => TypeGraphQL.ID, {
nullable: false,
})
uuid!: string;

// ...
}