()
| 70 | } |
| 71 | |
| 72 | func (p *parser) parseSchemaDocument() *SchemaDocument { |
| 73 | var doc SchemaDocument |
| 74 | doc.Position = p.peekPos() |
| 75 | for p.peek().Kind != lexer.EOF { |
| 76 | if p.err != nil { |
| 77 | return nil |
| 78 | } |
| 79 | |
| 80 | var description descriptionWithComment |
| 81 | if p.peek().Kind == lexer.BlockString || p.peek().Kind == lexer.String { |
| 82 | description = p.parseDescription() |
| 83 | } |
| 84 | |
| 85 | if p.peek().Kind != lexer.Name { |
| 86 | p.unexpectedError() |
| 87 | break |
| 88 | } |
| 89 | |
| 90 | switch p.peek().Value { |
| 91 | case "scalar", "type", "interface", "union", "enum", "input": |
| 92 | doc.Definitions = append(doc.Definitions, p.parseTypeSystemDefinition(description)) |
| 93 | case "schema": |
| 94 | doc.Schema = append(doc.Schema, p.parseSchemaDefinition(description)) |
| 95 | case "directive": |
| 96 | doc.Directives = append(doc.Directives, p.parseDirectiveDefinition(description)) |
| 97 | case "extend": |
| 98 | if description.text != "" { |
| 99 | p.unexpectedToken(p.prev) |
| 100 | } |
| 101 | p.parseTypeSystemExtension(&doc) |
| 102 | default: |
| 103 | p.unexpectedError() |
| 104 | return nil |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | // treat end of file comments |
| 109 | doc.Comment = p.comment |
| 110 | |
| 111 | return &doc |
| 112 | } |
| 113 | |
| 114 | func (p *parser) parseDescription() descriptionWithComment { |
| 115 | token := p.peek() |
no test coverage detected