Interface Type
- 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
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
static enum
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAnnotation
(String annotationToAdd) The annotation setter should be added.void
addAnnotation
(String annotationToAdd, boolean replace) The annotation setter should be added.void
Add the given class as an import for the current type.void
addImportForUtilityClasses
(String targetPackageName, String classname) Same as#addImport(String, String, String)
, but for the utility classesReturns the annotation or annotations that must be added to this type.Returns the list of directives that have been defined for this type, in the GraphQL schemaReturns the camel case String, based on the object's name.default String
The java class full name for this type.The java class simple name for this type.Returns the comments that have been found before this object, in the provided GraphQL schemadefault DataFetcher
Returns theDataFetcher
that is associated to this type.Returns the description for this object, in the provided GraphQL schemadefault Field
Returns the Field of the given nameReturns the list ofField
s for this type.The GraphQlType for this typeReturns the identifier for this type.Get the list of imports for this object, for classes in theGenerateCodeCommonConfiguration.getPackageName()
.Get the list of imports for this object, for classes in the utility package, that is for utility classes whenGenerateCodeCommonConfiguration.isSeparateUtilityClasses()
is true.default String
The name of the field, as it can be used in the Java code.getName()
The GraphQL name of the object typeReturns the package's name where the GraphQL objects from the GraphQL schema must be generated.default String
Returns "query", "mutation" or "subscription" if this type is a query, mutation or subscription.default String
getTargetFileName
(Type.TargetFileType fileType) Get the filename where this type must be created.boolean
Returns true if this type is a GraphQL Custom Scalar, false otherwisedefault boolean
isEnum()
Returns true if this type is a GraphQL enum, false otherwiseboolean
Returns true if this type is a GraphQL InputObjectType, false otherwiseboolean
isScalar()
Returns true if this type is a GraphQL Scalar (custom or not), false otherwise
-
Method Details
-
getDataFetcher
Returns theDataFetcher
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
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
Get the filename where this type must be created. Default is to return the name for the Type -
getImports
Get the list of imports for this object, for classes in theGenerateCodeCommonConfiguration.getPackageName()
. It's an order Set, so that the generated java file is clean.- Returns:
-
getImportsForUtilityClasses
Get the list of imports for this object, for classes in the utility package, that is for utility classes whenGenerateCodeCommonConfiguration.isSeparateUtilityClasses()
is true. It's an order Set, so that the generated java file is clean.- Returns:
-
addImport
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 theClass.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 generatedclassname
- The full class name (java.lang.String for instance) of the class to import
-
addImportForUtilityClasses
Same as#addImport(String, String, String)
, but for the utility classes- Parameters:
targetPackageName
- The package where the objects are generatedclassname
- 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
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
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
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
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
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
Returns the list ofField
s 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
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
-