Skip to content

Implement Descriptions in .graphql files #12

@schrockn

Description

@schrockn

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 graphql/graphql-js@165b9d3 . 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!]!
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions