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 }
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()) }
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) }