SerializationBackend

Selects which serialization annotations the code generator emits.

Backend Behavior

NONE

No serialization annotations emitted. Generated classes remain plain data holders. Useful for consumers who bring their own serialization or who only need the operation constants, registry, and variable types without JSON serialization metadata.

NONE may be combined with generateResponses = true: response models, including sealed interfaces for abstract (interface/union) types, are emitted as plain Kotlin structures with no serializer imports, annotations, or adapters. NONE is never upgraded to another backend.

KOTLINX

Emits @Serializable on classes and sealed interfaces, @SerialName on properties and enum constants, and @JsonClassDiscriminator("__typename") on sealed polymorphism roots. It is an optional backend for response model generation. kotlinx.serialization is R8-safe by default (no custom keep rules needed for generated types).

GSON

Emits @SerializedName on properties and enum constants. Gson does not require a class-level annotation, so none is emitted. Gson uses runtime reflection; R8 keep rules may be needed depending on usage.

Limitation: Gson cannot deserialize polymorphic sealed interfaces, which are needed for GraphQL union and interface response types. Using GSON with generateResponses = true is only supported for operations whose response types are concrete (no interfaces or unions).

DSL Integration

Configure via the Gradle DSL:

retrofitGraphQL {
common {
serializationBackend.set(SerializationBackend.KOTLINX)
}
}

See also: RetrofitGraphQLExtension.serializationBackend (DSL property).

Since

1.0

Entries

Link copied to clipboard

No serialization annotations emitted.

Link copied to clipboard

kotlinx.serialization annotations (@Serializable, @SerialName).

Link copied to clipboard

Gson annotations (@SerializedName).

Properties

Link copied to clipboard

Returns a representation of an immutable list of all enum entries, in the order they're declared.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Link copied to clipboard

Returns an array containing the constants of this enum type, in the order they're declared.