ModelValueConverter
public protocol ModelValueConverter
Establishes how Model fields should be converted to and from different targets (e.g. SQL and GraphQL).
Warning
Although this haspublic access, it is intended for internal use and should not be used directly
by host applications. The behavior of this may change without warning.
-
The base type on the source (i.e. the
Modelproperty type)Declaration
Swift
associatedtype SourceType -
The type on the target (i.e. the
SQLvalue type)Declaration
Swift
associatedtype TargetType -
Converts a source value of a certain type to the target type
Declaration
Swift
static func convertToTarget(from source: SourceType, fieldType: ModelFieldType) throws -> TargetTypeReturn Value
the converted value
-
Converts a target value of a certain type to the
Modelfield typeDeclaration
Swift
static func convertToSource(from target: TargetType, fieldType: ModelFieldType) throws -> SourceTypeParameters
targetthe value from the target
fieldTypethe type of the
ModelfieldReturn Value
the converted value to the expected
ModelFieldType -
toJSON(_:Extension method) Warning
Although this haspublicaccess, it is intended for internal & codegen use and should not be used directly by host applications. The behavior of this may change without warning. Though it is not used by host application making any change to thesepublictypes should be backward compatible, otherwise it will be a breaking change.Declaration
Swift
public static func toJSON(_ value: Encodable) throws -> String? -
fromJSON(_:Extension method) Warning
Although this haspublicaccess, it is intended for internal & codegen use and should not be used directly by host applications. The behavior of this may change without warning. Though it is not used by host application making any change to thesepublictypes should be backward compatible, otherwise it will be a breaking change.Declaration
Swift
public static func fromJSON(_ value: String) throws -> Any?
View on GitHub