graphscale icon indicating copy to clipboard operation
graphscale copied to clipboard

Implement Descriptions in .graphql files

Open schrockn opened this issue 7 years ago • 0 comments

Right now it is not possible to embed descriptions in the graphql files. This is bad. We should be able to write docs inline with the type declarations.

This actually requires changes to graphql-core. A similar change was made to graphql-js here https://github.com/graphql/graphql-js/commit/165b9d3a0b913d792501b0ce2829ad417d83122d . This should be mimicked in graphql-core. The idea to make comments a lexed token, make the stream of lexed tokens a doubly linked list that skips those comments by default. This allows another piece of code to consume the linked list but "peek" backwards to see if there is a comment. If there is, we can see consume that token and produce descriptions as appropriate.

Seems like the best first stab would be to indicate description versus comments by prefixing "##" for descriptions.

# this is a comment that will not appear in the description
## This is a description of User
type User {
   # this is not a description
   id: UUID!
   ## This is a description of name
   name: String!
   ## Description of TodoList
   todoLists(
      ## This is a description of first  
      first: Int = 100, 
      ## This is a description of after
      after: UUID): [TodoList!]!
}

schrockn avatar Jul 03 '17 01:07 schrockn