Interface GQLFragment

  • All Superinterfaces:
    GQLSelection
    All Known Implementing Classes:
    GQLFragmentDefinition, GQLFragmentReference, GQLInlineFragment

    public interface GQLFragment
    extends GQLSelection
    A fragment is a piece of a field list representing a single type as part of a struct, union, union list, interface list etc. E.g. consider the graphql type structure:
    
     interface Character {
         name: String!
         appears_in: [Movie!]!
     }
     type Human implements Character {
         height: Float!
     }
     type Droid implements Character {
         purpose: String!
     }
     union CharacterUnion = Human | Droid
     type Query {
       hero: CharacterUnion
     }
     
    And the query document:
    
     {
         hero {
             name
             ... on Droid {
                 purpose
             }
             ... HumanFields
         }
     }
    
     fragment HumanFields on Human {
         height
     }
     
    Here ...of Droid is an inline fragment, and HumanFields is a fragment reference and definition.
    • Method Detail

      • getTypeCondition

        @Nonnull
        net.morimekta.providence.descriptor.PMessageDescriptor<?> getTypeCondition()
        All fragments represent a specific message type of a union field, or an interface implementation. This should return the descriptor of that message type.
        Returns:
        The fragment type descriptor.
      • isApplicableFor

        default boolean isApplicableFor​(net.morimekta.providence.descriptor.PMessageDescriptor containingType)
        Parameters:
        containingType - Containing type to check.
        Returns:
        True if the fragment should be applied when writing content for the containing message type.