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

Method parseDirectiveDefinition

parser/schema.go:553–573  ·  view source on GitHub ↗
(description descriptionWithComment)

Source from the content-addressed store, hash-verified

551}
552
553func (p *parser) parseDirectiveDefinition(description descriptionWithComment) *DirectiveDefinition {
554 _, comment := p.expectKeyword("directive")
555 p.expect(lexer.At)
556
557 var def DirectiveDefinition
558 def.Position = p.peekPos()
559 def.BeforeDescriptionComment = description.comment
560 def.Description = description.text
561 def.AfterDescriptionComment = comment
562 def.Name = p.parseName()
563 def.Arguments = p.parseArgumentDefs()
564
565 if peek := p.peek(); peek.Kind == lexer.Name && peek.Value == "repeatable" {
566 def.IsRepeatable = true
567 p.skip(lexer.Name)
568 }
569
570 p.expectKeyword("on")
571 def.Locations = p.parseDirectiveLocations()
572 return &def
573}
574
575func (p *parser) parseDirectiveLocations() []DirectiveLocation {
576 p.skip(lexer.Pipe)

Callers 1

parseSchemaDocumentMethod · 0.95

Calls 8

expectKeywordMethod · 0.95
expectMethod · 0.95
peekPosMethod · 0.95
parseNameMethod · 0.95
parseArgumentDefsMethod · 0.95
peekMethod · 0.95
skipMethod · 0.95

Tested by

no test coverage detected