Пример #1
0
func init() {
	name = parsec.Maybe(identFn, parsec.Ident())

	// missing `fragment spread`, `inline fragment`
	selection := parsec.OrdChoice(extract(0), field())
	selectionSet = parsec.And(extract(1), parsec.Token(`{`, ""), parsec.Many(fieldArrayify, selection), parsec.Token(`}`, ""))

	// missing `fragment definition`, `type definition`
	definition := operationDefinition()
	document := parsec.OrdChoice(extract(0), parsec.Maybe(shorthandQueryify, selectionSet), parsec.Many(fieldArrayify, definition))

	y = document
}
Пример #2
0
func field() parsec.Parser {

	alias := parsec.And(identFn, parsec.Ident(), parsec.Token(`:`, ""))

	arguments := parsec.And(
		extract(1),
		parsec.Token(`\(`, ""),
		parsec.Many(
			argify,
			// `Argument` list
			parsec.And(nil, parsec.Maybe(identFn, parsec.Ident()), parsec.Token(`:`, ""), value())),
		parsec.Token(`\)`, ""))

	// Missing `directives`
	return sequence(queryify, &alias, &name, &arguments, &selectionSet)
}