Attach comments to enum values
See original GitHub issueProblem
/// user role
enum Role {
ADMIN /// allowed to do everything
USER
}
Comment allowed to do everything
is not attached to the ADMIN value in the DMMF generator.
Generator DMMF output
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
datasource db {
provider = "postgres"
url = env("POSTGRESQL_URL")
}
generator client {
provider = "prisma-client-js"
}
generator dbml {
provider = "node ./dist/generator.js"
}
model User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
email String @unique
name String?
posts Post[]
profile Profile?
/// user role
role Role @default(USER)
}
/// User profile
model Profile {
id Int @default(autoincrement()) @id
bio String?
user User @relation(fields: [userId], references: [id])
userId Int @unique
}
model Post {
id Int @id @default(autoincrement())
title String @default("")
content String?
published Boolean @default(false)
author User? @relation(fields: [authorId], references: [id])
authorId Int?
categories Category[]
}
model Category {
id Int @id @default(autoincrement())
name String
posts Post[]
}
/// user role
enum Role {
ADMIN /// allowed to do everything
USER
}
{
"enums": [
{
"name": "Role",
"values": [
{ "name": "ADMIN", "dbName": null },
{ "name": "USER", "dbName": null }
],
"dbName": null,
"documentation": "user role"
}
],
"models": [
{
"name": "User",
"isEmbedded": false,
"dbName": null,
"fields": [
{
"name": "id",
"kind": "scalar",
"isList": false,
"isRequired": true,
"isUnique": false,
"isId": true,
"isReadOnly": false,
"type": "Int",
"hasDefaultValue": true,
"default": { "name": "autoincrement", "args": [] },
"isGenerated": false,
"isUpdatedAt": false
},
{
"name": "createdAt",
"kind": "scalar",
"isList": false,
"isRequired": true,
"isUnique": false,
"isId": false,
"isReadOnly": false,
"type": "DateTime",
"hasDefaultValue": true,
"default": { "name": "now", "args": [] },
"isGenerated": false,
"isUpdatedAt": false
},
{
"name": "updatedAt",
"kind": "scalar",
"isList": false,
"isRequired": true,
"isUnique": false,
"isId": false,
"isReadOnly": false,
"type": "DateTime",
"hasDefaultValue": false,
"isGenerated": false,
"isUpdatedAt": true
},
{
"name": "email",
"kind": "scalar",
"isList": false,
"isRequired": true,
"isUnique": true,
"isId": false,
"isReadOnly": false,
"type": "String",
"hasDefaultValue": false,
"isGenerated": false,
"isUpdatedAt": false
},
{
"name": "name",
"kind": "scalar",
"isList": false,
"isRequired": false,
"isUnique": false,
"isId": false,
"isReadOnly": false,
"type": "String",
"hasDefaultValue": false,
"isGenerated": false,
"isUpdatedAt": false
},
{
"name": "posts",
"kind": "object",
"isList": true,
"isRequired": false,
"isUnique": false,
"isId": false,
"isReadOnly": false,
"type": "Post",
"hasDefaultValue": false,
"relationName": "PostToUser",
"relationFromFields": [],
"relationToFields": [],
"relationOnDelete": "NONE",
"isGenerated": false,
"isUpdatedAt": false
},
{
"name": "profile",
"kind": "object",
"isList": false,
"isRequired": false,
"isUnique": false,
"isId": false,
"isReadOnly": false,
"type": "Profile",
"hasDefaultValue": false,
"relationName": "ProfileToUser",
"relationFromFields": [],
"relationToFields": [],
"relationOnDelete": "NONE",
"isGenerated": false,
"isUpdatedAt": false
},
{
"name": "role",
"kind": "enum",
"isList": false,
"isRequired": true,
"isUnique": false,
"isId": false,
"isReadOnly": false,
"type": "Role",
"hasDefaultValue": true,
"default": "USER",
"isGenerated": false,
"isUpdatedAt": false,
"documentation": "user role"
}
],
"isGenerated": false,
"idFields": [],
"uniqueFields": [],
"uniqueIndexes": []
},
...
]
}
Suggested solution
Attach comments to enum values
interface EnumValue {
name: string;
dbName: string;
+ documentation?: string;
}
interface DatamodelEnum {
name: string;
values: EnumValue[];
dbName?: string | null;
documentation?: string;
}
Alternatives
Additional context
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:5 (2 by maintainers)
Top Results From Across the Web
c# - How do I comment a publicly visible type Enum?
Yes I realize that comments are unnecessary, but if commenting is easy and it resolves the warnings then I'd like to do it....
Read more >Attaching Values to Java Enum - Baeldung
Let's start by adding the element names. ... First of all, we notice the special syntax in the declaration list. This is how...
Read more >Documenting Enum Values - MSDN - Microsoft
Hi,. Your commas are misplaced. The summaries below "Insert" are not applied to anything - they are just floating before a comma. Try ......
Read more >PostGraphile | Enums
The @enum smart comments can be used to set the name ( @enumName ) or the ... a PostgreSQL enum, and you cannot...
Read more >Language Guide (proto3) | Protocol Buffers - Google Developers
To add comments to your .proto files, use C/C++-style // and /* . ... For enums, the default value is the first defined...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi There,
I am using prisma-nestjs-graphql generator and this is stopping the comments from the schema showing up in the generated registerEnumType.
https://github.com/unlight/prisma-nestjs-graphql/issues/43#issuecomment-904200469
Issue #13726 has been opened for composite type comments.