@@ -172,14 +172,10 @@ impl From<graphql_parser::schema::InputValue<'_, String>> for Field {
172172
173173struct FieldContext < ' a > {
174174 field : & ' a Field ,
175- deserialize_only : bool ,
176175}
177176impl < ' a > FieldContext < ' a > {
178- fn new ( field : & ' a Field , deserialize_only : bool ) -> Self {
179- Self {
180- field,
181- deserialize_only,
182- }
177+ fn new ( field : & ' a Field ) -> Self {
178+ Self { field }
183179 }
184180}
185181impl ToTokens for FieldContext < ' _ > {
@@ -201,11 +197,6 @@ impl ToTokens for FieldContext<'_> {
201197 serde_options. push ( quote_spanned ! { span=>
202198 default
203199 } ) ;
204- if !self . deserialize_only {
205- serde_options. push ( quote_spanned ! { span=>
206- skip_serializing_if = "Option::is_none"
207- } ) ;
208- }
209200 }
210201 if !serde_options. is_empty ( ) {
211202 tokens. extend ( quote_spanned ! { span=>
@@ -221,7 +212,6 @@ impl ToTokens for FieldContext<'_> {
221212struct Structure {
222213 name : Name ,
223214 fields : Vec < Field > ,
224- deserialize_only : bool ,
225215}
226216impl Structure {
227217 fn apply_type_overrides (
@@ -315,39 +305,23 @@ impl From<graphql_parser::schema::ObjectType<'_, String>> for Structure {
315305 fn from ( value : graphql_parser:: schema:: ObjectType < ' _ , String > ) -> Self {
316306 let name = Name :: from ( ( value. name , current_span ( ) ) ) ;
317307 let fields = value. fields . into_iter ( ) . map ( Field :: from) . collect ( ) ;
318- Self {
319- name,
320- fields,
321- deserialize_only : false ,
322- }
308+ Self { name, fields }
323309 }
324310}
325311impl From < graphql_parser:: schema:: InputObjectType < ' _ , String > > for Structure {
326312 fn from ( value : graphql_parser:: schema:: InputObjectType < ' _ , String > ) -> Self {
327313 let name = Name :: from ( value. name ) ;
328314 let fields = value. fields . into_iter ( ) . map ( Field :: from) . collect ( ) ;
329- Self {
330- name,
331- fields,
332- deserialize_only : true ,
333- }
315+ Self { name, fields }
334316 }
335317}
336318impl ToTokens for Structure {
337319 fn to_tokens ( & self , tokens : & mut proc_macro2:: TokenStream ) {
338320 let span = current_span ( ) ;
339321 let struct_name = self . name . to_type_ident ( ) ;
340- let fields = self
341- . fields
342- . iter ( )
343- . map ( |f| FieldContext :: new ( f, self . deserialize_only ) ) ;
344- let serde_derive = if self . deserialize_only {
345- quote_spanned ! { span=>:: lambda_appsync:: serde:: Deserialize }
346- } else {
347- quote_spanned ! { span=>:: lambda_appsync:: serde:: Serialize , :: lambda_appsync:: serde:: Deserialize }
348- } ;
322+ let fields = self . fields . iter ( ) . map ( FieldContext :: new) ;
349323 tokens. extend ( quote_spanned ! { span=>
350- #[ derive( Debug , Clone , #serde_derive ) ]
324+ #[ derive( Debug , Clone , :: lambda_appsync :: serde :: Serialize , :: lambda_appsync :: serde :: Deserialize ) ]
351325 pub struct #struct_name {
352326 #( #fields, ) *
353327 }
0 commit comments