Example #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
}
Example #2
0
func value() parsec.Parser {
	//   Variable (not implemented)
	//   IntValue
	//   FloatValue (not implemented)
	//   StringValue
	//   BooleanValue (not implemented)
	//   EnumValue (not implemented)
	//   ListValueConst (not implemented)
	//   ObjectValueConst (not implemented)
	return parsec.OrdChoice(valueify, parsec.Int(), parsec.String())
}
Example #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)
}