Search code examples
schemagraphqlprismaprisma-graphql

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


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:


Solution

  • The answer is here: https://www.prisma.io/forum/t/comments-in-prisma-graphql-from-datamodel-graphql/4330/2?u=alan345

    Currently, there’s no easy way to resolve this. This is an open feature request, which you can learn more about here: https://github.com/prisma/prisma/issues/2152