-
Notifications
You must be signed in to change notification settings - Fork 656
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce InputType for optional values with undefined state
Introduce wrapper class InputType for optional values that can be in 3 states: some value, null and undefined. Update generation of input object types to utilize new InputType wrapper and don't serialize optional value if it's undefined. Closes #652
- Loading branch information
Showing
15 changed files
with
411 additions
and
272 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
apollo-api/src/main/java/com/apollographql/apollo/api/Input.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.apollographql.apollo.api; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public final class Input<V> { | ||
public final V value; | ||
public final boolean defined; | ||
|
||
private Input(V value, boolean defined) { | ||
this.value = value; | ||
this.defined = defined; | ||
} | ||
|
||
public static <V> Input<V> fromNullable(@Nullable V value) { | ||
return new Input<>(value, true); | ||
} | ||
|
||
public static <V> Input<V> absent() { | ||
return new Input<>(null, false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.