Exemplo n.º 1
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)
}
Exemplo n.º 2
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
}
Exemplo n.º 3
0
func operationDefinition() parsec.Parser {
	operationType := parsec.OrdChoice(extract(0), parsec.Token(`query`, "OP_TYPE_QUERY"), parsec.Token(`mutation`, "OP_TYPE_MUTATION"))

	// missing `variable definitions`, `directives`
	return sequence(operationDefinitionify, &operationType, &name, &selectionSet)
}