This repository was archived by the owner on Nov 12, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +25
-7
lines changed
main/kotlin/com/apollographql/apollo/compiler
fragments_with_type_condition_nullable Expand file tree Collapse file tree 3 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -222,7 +222,7 @@ class SchemaTypeSpecBuilder(
222222 fun responseMarshallerSpec (fieldSpecs : List <FieldSpec >): MethodSpec {
223223 val code = fieldSpecs
224224 .map { fieldSpec ->
225- if (fieldSpec.type.isOptional ()) {
225+ if (fieldSpec.type.isNullable ()) {
226226 CodeBlock .builder()
227227 .addStatement(" final \$ T \$ L = \$ L" , fieldSpec.type.unwrapOptionalType().withoutAnnotations(),
228228 " \$ ${fieldSpec.name} " , fieldSpec.type.unwrapOptionalValue(fieldSpec.name))
Original file line number Diff line number Diff line change @@ -377,8 +377,14 @@ public ResponseFieldMarshaller marshaller() {
377377 return new ResponseFieldMarshaller () {
378378 @ Override
379379 public void marshal (ResponseWriter writer ) {
380- writer .writeFragment (humanDetails .marshaller ());
381- writer .writeFragment (droidDetails .marshaller ());
380+ final HumanDetails $humanDetails = humanDetails ;
381+ if ($humanDetails != null ) {
382+ writer .writeFragment ($humanDetails .marshaller ());
383+ }
384+ final DroidDetails $droidDetails = droidDetails ;
385+ if ($droidDetails != null ) {
386+ writer .writeFragment ($droidDetails .marshaller ());
387+ }
382388 }
383389 };
384390 }
@@ -575,8 +581,14 @@ public ResponseFieldMarshaller marshaller() {
575581 return new ResponseFieldMarshaller () {
576582 @ Override
577583 public void marshal (ResponseWriter writer ) {
578- writer .writeFragment (humanDetails .marshaller ());
579- writer .writeFragment (droidDetails .marshaller ());
584+ final HumanDetails $humanDetails = humanDetails ;
585+ if ($humanDetails != null ) {
586+ writer .writeFragment ($humanDetails .marshaller ());
587+ }
588+ final DroidDetails $droidDetails = droidDetails ;
589+ if ($droidDetails != null ) {
590+ writer .writeFragment ($droidDetails .marshaller ());
591+ }
580592 }
581593 };
582594 }
Original file line number Diff line number Diff line change @@ -363,8 +363,14 @@ public ResponseFieldMarshaller marshaller() {
363363 return new ResponseFieldMarshaller () {
364364 @ Override
365365 public void marshal (ResponseWriter writer ) {
366- writer .writeFragment (character .marshaller ());
367- writer .writeFragment (starship .marshaller ());
366+ final Character $character = character ;
367+ if ($character != null ) {
368+ writer .writeFragment ($character .marshaller ());
369+ }
370+ final Starship $starship = starship ;
371+ if ($starship != null ) {
372+ writer .writeFragment ($starship .marshaller ());
373+ }
368374 }
369375 };
370376 }
You can’t perform that action at this time.
0 commit comments