Class GQLDefinition


  • @Immutable
    public class GQLDefinition
    extends java.lang.Object
    A GQL service is a collection of zero or more 'queries' and zero or more 'mutations'. The query and mutation distinction is meant to represent reading and writing operations, but in reality they distinguish parallel and serial execution, in case the query contains more than one base entry.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  GQLDefinition.Builder
      Builder for setting up a GraphQL definition.
    • Constructor Summary

      Constructors 
      Constructor Description
      GQLDefinition​(net.morimekta.providence.descriptor.PService query, net.morimekta.providence.descriptor.PService mutation, java.util.Collection<net.morimekta.providence.descriptor.PField<?>> idFields)
      Deprecated.
      Use Builder.
      GQLDefinition​(net.morimekta.providence.descriptor.PService query, net.morimekta.providence.descriptor.PService mutation, java.util.Collection<net.morimekta.providence.descriptor.PField<?>> idFields, java.util.Collection<net.morimekta.providence.descriptor.PUnionDescriptor<?>> asInterface)
      Deprecated.
      Use Builder.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static GQLDefinition.Builder builder()  
      net.morimekta.providence.graphql.introspection.Schema getIntrospectionSchema()
      Return the introspection schema for this definition.
      net.morimekta.providence.graphql.introspection.Type getIntrospectionType​(java.lang.String name)
      Get the introspection type for a defined type.
      net.morimekta.providence.graphql.introspection.Type getIntrospectionType​(net.morimekta.providence.descriptor.PDescriptor descriptor, boolean isInput)
      Get introspection type for a given descriptor.
      net.morimekta.providence.descriptor.PService getMutation()
      Get mutation by name, e.g. for gql queries like this:
      net.morimekta.providence.descriptor.PService getQuery()
      Get query, e.g. for gql queries like this:
      java.lang.String getSchema()
      Get a defined schema from the GQL service.
      net.morimekta.providence.descriptor.PDescriptor getType​(java.lang.String name)
      Get a type used in the GQL service.
      boolean isIgnoredField​(net.morimekta.providence.descriptor.PField<?> field)
      If the field should be ignored.
      boolean isIgnoredType​(net.morimekta.providence.descriptor.PDescriptor descriptor)
      If the type should be ignored.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GQLDefinition

        @Deprecated
        public GQLDefinition​(@Nonnull
                             net.morimekta.providence.descriptor.PService query,
                             @Nullable
                             net.morimekta.providence.descriptor.PService mutation,
                             @Nonnull
                             java.util.Collection<net.morimekta.providence.descriptor.PField<?>> idFields)
        Deprecated.
        Use Builder.
        Create a graphql definition instance.
        Parameters:
        query - The query service. Mandatory.
        mutation - The mutation service.
        idFields - Collection if ID fields.
      • GQLDefinition

        @Deprecated
        public GQLDefinition​(@Nonnull
                             net.morimekta.providence.descriptor.PService query,
                             @Nullable
                             net.morimekta.providence.descriptor.PService mutation,
                             @Nonnull
                             java.util.Collection<net.morimekta.providence.descriptor.PField<?>> idFields,
                             @Nonnull
                             java.util.Collection<net.morimekta.providence.descriptor.PUnionDescriptor<?>> asInterface)
        Deprecated.
        Use Builder.
        Create a graphql definition instance.
        Parameters:
        query - The query service. Mandatory.
        mutation - The mutation service.
        idFields - Collection if ID fields.
        asInterface - Collection of unions to be
    • Method Detail

      • getQuery

        @Nonnull
        public net.morimekta.providence.descriptor.PService getQuery()
        Get query, e.g. for gql queries like this:
         {
             hero(id:1001) {
                 name
             }
         }
         
        Returns:
        The query service.
      • getMutation

        @Nullable
        public net.morimekta.providence.descriptor.PService getMutation()
        Get mutation by name, e.g. for gql queries like this:
         mutation HeroStore {
             deleteHero(id:1001) {
                 name
             }
         }
         
        Returns:
        The mutation service.
      • isIgnoredField

        public boolean isIgnoredField​(net.morimekta.providence.descriptor.PField<?> field)
        If the field should be ignored. This means not allowed in fragments or selection sets.
        Parameters:
        field - The field to check.
        Returns:
        True if the field should be ignored.
      • isIgnoredType

        public boolean isIgnoredType​(net.morimekta.providence.descriptor.PDescriptor descriptor)
        If the type should be ignored.
        Parameters:
        descriptor - The type
        Returns:
        If the type should be ignored.
      • getType

        public net.morimekta.providence.descriptor.PDescriptor getType​(@Nonnull
                                                                       java.lang.String name)
        Get a type used in the GQL service.
        Parameters:
        name - The name of the type.
        Returns:
        The type description, enum or message.
      • getIntrospectionType

        @Nullable
        public net.morimekta.providence.graphql.introspection.Type getIntrospectionType​(@Nonnull
                                                                                        java.lang.String name)
        Get the introspection type for a defined type.
        Parameters:
        name - The type name.
        Returns:
        Introspection type, or null if not defined in service.
      • getIntrospectionType

        @Nonnull
        public net.morimekta.providence.graphql.introspection.Type getIntrospectionType​(@Nonnull
                                                                                        net.morimekta.providence.descriptor.PDescriptor descriptor,
                                                                                        boolean isInput)
        Get introspection type for a given descriptor.
        Parameters:
        descriptor - The descriptor to get introspection type for.
        isInput - If the type should be an input type.
        Returns:
        The introspection type.
      • getSchema

        public java.lang.String getSchema()
        Get a defined schema from the GQL service.
        Returns:
        The GQL schema.
      • getIntrospectionSchema

        @Nonnull
        public net.morimekta.providence.graphql.introspection.Schema getIntrospectionSchema()
        Return the introspection schema for this definition.
        Returns:
        The schema.