Class MergedField


  • @PublicApi
    public class MergedField
    extends java.lang.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 Detail

      • getName

        public java.lang.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 java.lang.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 java.util.List<Argument> getArguments()
        All merged fields share the same arguments.
        Returns:
        the list of arguments
      • getFields

        public java.util.List<Field> getFields()
        All merged fields
        Returns:
        all merged fields
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object