Class MergedField

java.lang.Object
graphql.execution.MergedField

@PublicApi public class MergedField extends Object
This represents all Fields in a query which overlap and are merged into one. This means they all represent the same field actually when the query is executed. Example query with more than one Field merged together:
 

      query Foo {
          bar
          ...BarFragment
      }

      fragment BarFragment on Query {
          bar
      }
 
 
Another example:
 
     {
          me{fistName}
          me{lastName}
     }
 
 
Here the field is merged together including the sub selections. A third example with different directives:
 
     {
          foo @someDirective
          foo @anotherDirective
     }
 
 
These examples make clear that you need to consider all merged fields together to have the full picture. The actual logic when fields can be successfully merged together is implemented in {#graphql.validation.rules.OverlappingFieldsCanBeMerged}
  • Method Details

    • getName

      public String getName()
      All merged fields have the same name. WARNING: This is not always the key in the execution result, because of possible aliases. See getResultKey()
      Returns:
      the name of the merged fields.
    • getResultKey

      public String getResultKey()
      Returns the key of this MergedField for the overall result. This is either an alias or the field name.
      Returns:
      the key for this MergedField.
    • getSingleField

      public Field getSingleField()
      The first of the merged fields. Because all fields are almost identically often only one of the merged fields are used.
      Returns:
      the fist of the merged Fields
    • getArguments

      public List<Argument> getArguments()
      All merged fields share the same arguments.
      Returns:
      the list of arguments
    • getFields

      public List<Field> getFields()
      All merged fields
      Returns:
      all merged fields
    • getDeferredExecutions

      @ExperimentalApi public List<DeferredExecution> getDeferredExecutions()
      Get a list of all DeferredExecutions that this field is part of
      Returns:
      all defer executions.
    • isDeferred

      @ExperimentalApi public boolean isDeferred()
      Returns true if this field is part of a deferred execution
      Returns:
      true if this field is part of a deferred execution
    • newMergedField

      public static MergedField.Builder newMergedField()
    • newMergedField

      public static MergedField.Builder newMergedField(Field field)
    • newMergedField

      public static MergedField.Builder newMergedField(List<Field> fields)
    • transform

      public MergedField transform(Consumer<MergedField.Builder> builderConsumer)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object