src/GraphQL/Resources/graphql/definitions/union.pp2

Summary

Maintainability
Test Coverage


/**
 * --------------------------------------------------------------------------
 *  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
 */

#UnionDefinition -> Railt\GraphQL\AST\Definition\UnionNode
  : Description()?
    UnionDefinitionExceptDescription()
  ;

UnionDefinitionExceptDescription
  : UnionDefinitionHead()
    UnionDefinitionBody()?
  ;

UnionDefinitionHead
  : ::T_UNION:: TypeName()
    Directive()*
  ;

UnionDefinitionBody
  : ::T_EQUAL:: UnionDefinitionTargets()?
  ;

#UnionDefinitionTargets
  : ::T_OR::? TypeName() (
      ::T_OR:: TypeName()
    )*
  ;