MCPcopy Create free account
hub / github.com/vektah/gqlparser / parseSchemaDocument

Method parseSchemaDocument

parser/schema.go:72–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70}
71
72func (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
114func (p *parser) parseDescription() descriptionWithComment {
115 token := p.peek()

Callers 2

ParseSchemaFunction · 0.95
ParseSchemaWithLimitFunction · 0.95

Calls 9

peekPosMethod · 0.95
peekMethod · 0.95
parseDescriptionMethod · 0.95
unexpectedErrorMethod · 0.95
parseSchemaDefinitionMethod · 0.95
unexpectedTokenMethod · 0.95

Tested by

no test coverage detected