With Prisma, How can we add a comment for a Type?

Viewed 2657

With prisma.io (graphQl), we have:

  • File: datamodel.graphql
"""I am a great User"""
type User {
  id: ID! @unique
  email: String! @unique
}

after doing prisma deploy, it generates a file without the comment from the file datamodel.graphql

  • File generated-schema.graphql
type User implements Node {
  id: ID!
  email: String!
}
  • In the prisma playground, I do not have the comment. enter image description here

How can we add a comment for a Type in order to generate a documentation in playground?

Workaround:

If I cheat and add a comment in the generated-schema.graphql (this file will be overridden after the next prisma deploy)

"""I am a great User""" type User implements Node { id: ID! email: String! }

we have: enter image description here

Related topics:

2 Answers

Tools like Nexus allow for it. Optional descriptions could be included along with types and individual fields.

Ref to docs

Related