prisma-nestjs-graphql icon indicating copy to clipboard operation
prisma-nestjs-graphql copied to clipboard

Is there a way to get Prisma comments to become Graphql descriptions?

Open SynergyEvolved opened this issue 3 years ago • 7 comments

Hi there! I was wondering if its possible to get the comments from the prisma schema (link to docs) to show up in the { description: } section?

Thanks

Paul

SynergyEvolved avatar Aug 20 '21 00:08 SynergyEvolved

Triple comments of models will be copied to description property of ObjectType decorator, and will be visible in graphql schema. https://github.com/unlight/prisma-nestjs-graphql/blob/8896256a8e9eaf4422f2a1939889b8926b61f2a4/prisma/schema.prisma#L27-L29

unlight avatar Aug 20 '21 20:08 unlight

Thanks unlight - that works perfectly!

Is there a way to get the comments on an enum in Prisma to become part of the valuesMap of the registerEnumType?

Eg.

enum Visability {   /// A
  VISABLE /// The item is visable 
  HIDDEN /// The item is hidden
}

result:

import { registerEnumType } from '@nestjs/graphql'

export enum Visability  {
    VISABLE = 'VISABLE',
    HIDDEN = 'HIDDEN',
}


registerEnumType(Visability, {
    name: 'Visability',
    description: 'A',
    valuesMap: {
        VISABLE: {
            description: 'The item is visable ',
        },
        HIDDEN: {
            description: 'The item is hidden',
        },
    },
})

SynergyEvolved avatar Aug 23 '21 23:08 SynergyEvolved

I'll check

unlight avatar Aug 27 '21 17:08 unlight

Not possible, Prisma does not expose documentation (triple comments) for enum values.

unlight avatar Aug 27 '21 20:08 unlight

@SynergyEvolved Can you create a feature request in http://github.com/prisma/prisma?

unlight avatar Aug 27 '21 20:08 unlight

I have also opened an issue with the prisma team that comments get exposed on composite types. Apparently that was intended but just overlooked.

dieeisenefaust avatar Jun 09 '22 20:06 dieeisenefaust

Resolved by https://github.com/prisma/prisma-engines/pull/4034 https://github.com/prisma/prisma-engines/pull/4037

Expected to be released with 4.16.0

michaelpoellath avatar Jun 14 '23 12:06 michaelpoellath