All Known Subinterfaces:
CustomScalar
All Known Implementing Classes:
AbstractType, CustomScalarType, EnumType, InterfaceType, ObjectType, ScalarType, UnionType

public interface Type
All types found in the GraphQL schema(s), and discovered during the GraphQL parsing, are instance of Type.
Author:
etienne-sf
  • Method Details

    • getDataFetcher

      default DataFetcher getDataFetcher()
      Returns the DataFetcher that is associated to this type. This is used only when generating server side code: it allows to manage GraphQL fields that have arguments. For these fields, if generateDataFetcherForAllFieldsWithArgument is true, then data fetcher is generated even if the field is a scalar or an enum.
      Returns:
    • getName

      String getName()
      The GraphQL name of the object type
      Returns:
    • getJavaName

      default String getJavaName()
      The name of the field, as it can be used in the Java code. If the name is a java keyword (class, default, break...), the java name it prefixed by an underscore.
      If a prefix or a suffix has been defined in the plugin configuration for this kind of item (object type, union, enum...), then the java name contains the prefix and/or the suffix
      Returns:
      The name of the type, as it can be used in Java code
    • getPackageName

      String getPackageName()
      Returns the package's name where the GraphQL objects from the GraphQL schema must be generated.
      Returns:
    • getTargetFileName

      default String getTargetFileName(Type.TargetFileType fileType)
      Get the filename where this type must be created. Default is to return the name for the Type
    • getImports

      Set<String> getImports()
      Get the list of imports for this object, for classes in the GenerateCodeCommonConfiguration.getPackageName(). It's an order Set, so that the generated java file is clean.
      Returns:
    • getImportsForUtilityClasses

      Set<String> getImportsForUtilityClasses()
      Get the list of imports for this object, for classes in the utility package, that is for utility classes when GenerateCodeCommonConfiguration.isSeparateUtilityClasses() is true. It's an order Set, so that the generated java file is clean.
      Returns:
    • addImport

      void addImport(String targetPackageName, String classname)
      Add the given class as an import for the current type. This import will be added only if the given class is not in the same package as the java class for this type, and if it doesn't already exist in the imports set.
      classes from the java.lang package are not imported.
      Note1: for inner class, the classname may be "MainClassname$InnerClassname" (as returned by the Class.getName() method), par as "MainClassname.InnerClassname".
      Note2: it is not allowed to import a class of the same name as the current class: there would be a name conflict. In this case, the import "silently fails": the class is not imported in the imports list.
      Parameters:
      targetPackageName - The package where the objects are generated
      classname - The full class name (java.lang.String for instance) of the class to import
    • addImportForUtilityClasses

      void addImportForUtilityClasses(String targetPackageName, String classname)
      Same as #addImport(String, String, String), but for the utility classes
      Parameters:
      targetPackageName - The package where the objects are generated
      classname - The full class name (java.lang.String for instance) of the class to import
    • getAnnotation

      String getAnnotation()
      Returns the annotation or annotations that must be added to this type.
      Returns:
      The relevant annotation(s) ready to add directly as-is in the Velocity template, or "" (an empty string) if there is no annotation to add. The return is never null.
    • addAnnotation

      void addAnnotation(String annotationToAdd)
      The annotation setter should be added. This method allows to properly manage indentation in the generated source code
      Parameters:
      annotationToAdd - The annotation, that will be added to the current one
    • addAnnotation

      void addAnnotation(String annotationToAdd, boolean replace)
      The annotation setter should be added. This method allows to properly manage indentation in the generated source code
      Parameters:
      annotationToAdd - The annotation, that will be added to the current one
    • getComments

      List<String> getComments()
      Returns the comments that have been found before this object, in the provided GraphQL schema
    • getDescription

      Description getDescription()
      Returns the description for this object, in the provided GraphQL schema
    • getGraphQlType

      Type.GraphQlType getGraphQlType()
      The GraphQlType for this type
      Returns:
    • getRequestType

      default String getRequestType()
      Returns "query", "mutation" or "subscription" if this type is a query, mutation or subscription. And null otherwise.
      Returns:
    • getClassSimpleName

      String getClassSimpleName()
      The java class simple name for this type. It may be and interface or a concrete class.
      Returns:
      The java classname is usually the name of the type. But in some case, collision my occur with the Java syntax. In this cas, this method will return a classname different from the name
    • getCamelCaseName

      String getCamelCaseName()
      Returns the camel case String, based on the object's name. For instance: bigFoot for a type named BigFoot
      Returns:
    • getClassFullName

      default String getClassFullName()
      The java class full name for this type. It may be an interface or a concrete class.
      Returns:
      The java classname is usually the name of the type. But in some case, collision my occur with the Java syntax. In this cas, this method will return a classname different from the name
    • getFields

      default List<Field> getFields()
      Returns the list of Fields for this type. Or null, if this field can't have any field, like a GraphQLScalar for instance
      Returns:
      It returns the list of Fields, or an empty list of there are not fields. It should never be null. The interface returns, by default, an empty list.
    • getField

      default Field getField(String fieldName) throws NoSuchFieldException
      Returns the Field of the given name
      Parameters:
      fieldName -
      Returns:
      Throws:
      NoSuchFieldException - If this type has not field of this name
    • getIdentifier

      Field getIdentifier()
      Returns the identifier for this type. Typically : the field which has an ID as a type.
      Returns:
      The identifier for this type, or null of this type has no identifier or multiplier identifers (that is: multiple identifiers or identifier based on several fields are not currently managed)
    • isInputType

      boolean isInputType()
      Returns true if this type is a GraphQL InputObjectType, false otherwise
    • isScalar

      boolean isScalar()
      Returns true if this type is a GraphQL Scalar (custom or not), false otherwise
    • isCustomScalar

      boolean isCustomScalar()
      Returns true if this type is a GraphQL Custom Scalar, false otherwise
    • isEnum

      default boolean isEnum()
      Returns true if this type is a GraphQL enum, false otherwise
    • getAppliedDirectives

      List<AppliedDirective> getAppliedDirectives()
      Returns the list of directives that have been defined for this type, in the GraphQL schema