File: values.go

package info (click to toggle)
golang-github-graph-gophers-graphql-go 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,516 kB
  • sloc: sh: 373; javascript: 21; makefile: 5
file content (39 lines) | stat: -rw-r--r-- 846 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package common

import (
	"github.com/graph-gophers/graphql-go/ast"
)

func ParseInputValue(l *Lexer) *ast.InputValueDefinition {
	p := &ast.InputValueDefinition{}
	p.Loc = l.Location()
	p.Desc = l.DescComment()
	p.Name = l.ConsumeIdentWithLoc()
	l.ConsumeToken(':')
	p.TypeLoc = l.Location()
	p.Type = ParseType(l)
	if l.Peek() == '=' {
		l.ConsumeToken('=')
		p.Default = ParseLiteral(l, true)
	}
	p.Directives = ParseDirectives(l)
	return p
}

func ParseArgumentList(l *Lexer) ast.ArgumentList {
	var args ast.ArgumentList
	l.ConsumeToken('(')
	for l.Peek() != ')' {
		name := l.ConsumeIdentWithLoc()
		l.ConsumeToken(':')
		value := ParseLiteral(l, false)
		directives := ParseDirectives(l)
		args = append(args, &ast.Argument{
			Name:       name,
			Value:      value,
			Directives: directives,
		})
	}
	l.ConsumeToken(')')
	return args
}