You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Serialize value by converting to/from a proxy type with serde support.
This adapter serializes a type O by converting it into a second type T and serializing T. Deserializing works analogue, by deserializing a > T and then converting into O.
The latter eliminates the requirement for wrapper types and/or additional logic because it uses something that GraphQL already understands (i.e. u8, u16, String, ...).
Additionally, it can be used in conjunction with skip_input to eliminate it from an InputObject.
Code example
#[serde_as]#[derive(Serialize,Deserialize,SimpleObject,InputObject,Copy,Clone,Debug,PartialEq,Eq,Hash)]pubstructMyObject{#[serde_as(as = "FromInto<u8>")]#[graphql(as = "u8")]pubtype: external::enum::Type,// Assume u8 via impl From<u8> and impl From<external::enum::Type>#[serde_as(as = "FromInto<u16>")]#[serde_as(skip_input, as = "u16")]pubonly_object: external::Obj,// Assume u16 (only Object) via impl From<external::Obj> for u16pubname:String,}
type is external::enum::Type, however it is seen as an u8 in both SimpleObject and InputObject thanks to impl From<u8> for external::enum::Type and impl From<external::enum::Type> for u8
only_object is external::Obj, however it is seen as an u16 in SimpleObject thanks to impl From<external::enum::Type> for u16
only_object is skipped in InputObject thanks to skip_input
Description of the feature
I would like to include a feature similar to
serde_with::FromInto
:The latter eliminates the requirement for wrapper types and/or additional logic because it uses something that GraphQL already understands (i.e.
u8
,u16
,String
, ...).Additionally, it can be used in conjunction with
skip_input
to eliminate it from anInputObject
.Code example
type
isexternal::enum::Type
, however it is seen as anu8
in bothSimpleObject
andInputObject
thanks toimpl From<u8> for external::enum::Type
andimpl From<external::enum::Type> for u8
only_object
isexternal::Obj
, however it is seen as anu16
inSimpleObject
thanks toimpl From<external::enum::Type> for u16
only_object
is skipped inInputObject
thanks toskip_input
The text was updated successfully, but these errors were encountered: