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
Model
property type)Declaration
Swift
associatedtype SourceType
-
The type on the target (i.e. the
SQL
value 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 -> TargetType
Return Value
the converted value
-
Converts a target value of a certain type to the
Model
field typeDeclaration
Swift
static func convertToSource(from target: TargetType, fieldType: ModelFieldType) throws -> SourceType
Parameters
target
the value from the target
fieldType
the type of the
Model
fieldReturn Value
the converted value to the expected
ModelFieldType
-
toJSON(_:
Extension method) Warning
Although this haspublic
access, 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 thesepublic
types 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 haspublic
access, 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 thesepublic
types should be backward compatible, otherwise it will be a breaking change.Declaration
Swift
public static func fromJSON(_ value: String) throws -> Any?