resources/grammar/statement/definitions/type/union.pp2
/**
* --------------------------------------------------------------------------
* GraphQL SDL Unions
* --------------------------------------------------------------------------
*
* GraphQL Unions represent an object that could be one of a list of
* GraphQL Object types, but provides for no guaranteed fields between
* those types. They also differ from interfaces in that Object types
* declare what interfaces they implement, but are not aware of what unions
* contain them.
*
* @see https://facebook.github.io/graphql/June2018/#sec-Unions
*
*/
UnionTypeDefinition -> {
return new Stmt\Definition\UnionTypeDefinitionNode(
$children[1],
$children[0],
$children[3]->getArrayCopy(),
$children[2]->getArrayCopy(),
);
}
: Description()
UnionTypeDefinitionExceptDescription()
;
UnionTypeDefinitionExceptDescription
: UnionTypeDefinitionHead()
UnionTypeDefinitionBody()
;
UnionTypeDefinitionHead
: ::T_UNION:: Name() Directives()
;
OptionalUnionTypeDefinitionBody -> {
return $children === [] ? new \ArrayObject() : $children;
}
: UnionTypeDefinitionBody()?
;
UnionTypeDefinitionBody -> { return new \ArrayObject($children); }
: ::T_EQUAL:: UnionMemberTypes()
;
UnionMemberTypes
: ::T_OR::? NamedType() (::T_OR:: NamedType())*
;