prisma-labs/graphqlgen

Translate GraphQL Descriptions to Generated Types

jangerhofer opened this issue · 0 comments

Description

GraphQL descriptions are a common convention and are part of the GraphQL spec itself. These descriptions make tools like GraphQL Playground even more of a pleasure to use because the free-form descriptions can provide convenient comments on fields/types/queries/etc.

The convenience and context of those descriptions is lost when graphqlgen translates the schema into type definitions. Would it make sense for graphqlgen to preserve the information from schema descriptions in its output type definitions to better align the experience in an IDE with the ease of the Playground?

Additional context

I speak only from experience with VS Code & Atom, but I suspect that all major code editors support JSDoc in the auto-suggestion interface without any configuration (i.e. out of the box). It should be reasonably straightforward to, well, "forward" GraphQL descriptions through to JSDoc comments in the output type definitions, such that the descriptions can be displayed where the type definitions are used.

GraphQL Schema Input:

type Query {
  """
   Returns true 50% of the time; false the other 50%.
  """
  randomBoolean: Boolean!
}

Hypothetical graphqlgen Type Definition:

/**
  * Returns true 50% of the time; false the other 50%.
  */
   randomBoolean: (
      parent: undefined,
      args: {},
      ctx: Context,
      info: GraphQLResolveInfo
   ) => Boolean | Promise<Boolean>;

Of course, there are at least a few other places the description annotations could show up in the source schema (above type Query, for instance).

If this feature falls within the scope of graphqlgen, I'd be happy to work on implementing it.