Class UnionType

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.appsync.UnionType
All Implemented Interfaces:
IIntermediateType, software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:49.578Z") @Stability(Experimental) public class UnionType extends software.amazon.jsii.JsiiObject implements IIntermediateType
(experimental) Union Types are abstract types that are similar to Interface Types, but they cannot to specify any common fields between types.

Note that fields of a union type need to be object types. In other words, you can't create a union type out of interfaces, other unions, or inputs.

Example:

 GraphqlApi api;
 GraphqlType string = GraphqlType.string();
 ObjectType human = ObjectType.Builder.create("Human").definition(Map.of("name", string)).build();
 ObjectType droid = ObjectType.Builder.create("Droid").definition(Map.of("name", string)).build();
 ObjectType starship = ObjectType.Builder.create("Starship").definition(Map.of("name", string)).build();
 UnionType search = UnionType.Builder.create("Search")
         .definition(List.of(human, droid, starship))
         .build();
 api.addType(search);
 
  • Constructor Details

    • UnionType

      protected UnionType(software.amazon.jsii.JsiiObjectRef objRef)
    • UnionType

      protected UnionType(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • UnionType

      @Stability(Experimental) public UnionType(@NotNull String name, @NotNull UnionTypeOptions options)
      Parameters:
      name - This parameter is required.
      options - This parameter is required.
  • Method Details

    • addField

      @Stability(Experimental) public void addField(@NotNull AddFieldOptions options)
      (experimental) Add a field to this Union Type.

      Input Types must have field options and the IField must be an Object Type.

      Specified by:
      addField in interface IIntermediateType
      Parameters:
      options - the options to add a field. This parameter is required.
    • attribute

      @Stability(Experimental) @NotNull public GraphqlType attribute(@Nullable BaseTypeOptions options)
      (experimental) Create a GraphQL Type representing this Union Type.

      Specified by:
      attribute in interface IIntermediateType
      Parameters:
      options - the options to configure this attribute.
    • attribute

      @Stability(Experimental) @NotNull public GraphqlType attribute()
      (experimental) Create a GraphQL Type representing this Union Type.
      Specified by:
      attribute in interface IIntermediateType
    • toString

      @Stability(Experimental) @NotNull public String toString()
      (experimental) Generate the string of this Union type.
      Specified by:
      toString in interface IIntermediateType
      Overrides:
      toString in class Object
    • getDefinition

      @Stability(Experimental) @NotNull public Map<String,IField> getDefinition()
      (experimental) the attributes of this type.
      Specified by:
      getDefinition in interface IIntermediateType
    • getName

      @Stability(Experimental) @NotNull public String getName()
      (experimental) the name of this type.
      Specified by:
      getName in interface IIntermediateType
    • getModes

      @Stability(Experimental) @Nullable protected List<AuthorizationType> getModes()
      (experimental) the authorization modes supported by this intermediate type.
    • setModes

      @Stability(Experimental) protected void setModes(@Nullable List<AuthorizationType> value)
      (experimental) the authorization modes supported by this intermediate type.