DEV Community

Discussion on: GraphQL Code-First Approach with NestJS 7

Collapse
 
marcjulian profile image
Marc Stammerjohann • Edited

Hi Alex,

you can add a description option to the code first decorators @Query, @Mutation, @ObjectType, @Field and more.

Here is an example how to add a description:

@ObjectType({ description: 'Authentication Payload' })
export class Auth {
  @Field({ description: 'JWT Bearer Token for Authentication' })
  token: string;

   ....
}

This documentation is added to the generated graphql schema as comment """DESCRIPTION""" to the field or query, this is getting picked up by the graphql playground.

Let me know if this helps you.

Collapse
 
dadooda profile image
Alex Fortuna

Hey Marc,

Thank you for the info.

The recipe seems to work, just tried it in NestJS 7. Apollo's GraphQL Playground doesn't make descriptions quite visible though. But they are there (the "DOCS" tab).

The set of supported markups is yet to be discovered. Markdown's code seems to work, don't know about the rest.

Cheers!

Thread Thread
 
marcjulian profile image
Marc Stammerjohann

Good idea to add markdown to the docs that helps too.

I am glad I could help :)