EnumGenerator class
Generator for GraphQL enum types.
This class provides static methods for generating Dart enum definitions from GraphQL enum type definitions. It handles:
- Enum value generation with proper naming conventions
- Unknown enum value handling for forward compatibility
- Enum-to-string conversion support
- Deprecated enum value handling
The generator follows GraphQL best practices by automatically adding an UNKNOWN enum value to handle cases where the server returns enum values not known to the client (useful for schema evolution).
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- unknownEnumValue → EnumValueDefinition
-
Standard enum value for handling unknown enum values from the server.
final
Static Methods
-
addUnknownEnumValueAnnotation(
{required TypeNode fieldType, required TypeName dartTypeName, required Map< String, String> jsonKeyAnnotation}) → void - Add unknown enum value annotation for regular enum handling
-
generateEnum(
EnumTypeDefinitionNode node, Context context) → EnumDefinition - Generates a complete enum definition from a GraphQL enum type definition.
-
generateEnumValues(
List< EnumValueDefinitionNode> values, Context context) → List<EnumValueDefinition> - Generate enum value definitions from GraphQL enum value definition nodes
-
handleEnumToStringConversion(
{required TypeNode fieldType, required TypeName dartTypeName, required ClassPropertyName name, required Map< String, String> jsonKeyAnnotation}) → ClassProperty - Handle enum-to-string conversion logic for class properties