Search code examples
typescriptgraphqlnestjsnest

Documenting Graphql schema using Nestjs Code-first approach


Is there a way to add comments to mutations and queries of your schema generated through code first approach of Nestjs?


Solution

  • When using the decorators like @Field, @ObjectType and some others

    You can use description : 'some comment'

    And then you Will see the comments in graphql playground

    Example

    @ObjectType( {description : 'My class') )
    Class Person {
        @Field ( () => ID, { description : ' ID of the user' } ) 
        Id: number
    }