awslabs / awslabs/aws-mobile-appsync-sdk-android
No ability to serlialize null input fields
- Dominant language
- Java
- Stars
- 106
- Forks
- 56
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When a nullable input field is explicitly set to null, the null value should be propagated to the API to enable the semantic difference between an explicit null value and an omitted value to be communicated.
**To Reproduce**
Consider schema:
```
type ObjectWithNullable {
id: ID!
nullable: String
}
input InputWithNullable {
id: ID!
nullable: String
}
type Mutation {
update(input: InputWithNullables!): ObjectWithNullable! # Return value is immaterial
}
```
and graphql document:
```
mutation update($input: InputWithNullable!) {
update(input: $input) {
nullable
}
}
```
**Expected behavior**
In the generated code, when I invoke `update` with input and set `nullable` to null, the Input.fromNullable correctly returns an Input with `value` `null` and `defined` `true` however the null value is not serialised in to the request body by JsonWriter in `AppSyncOfflineMutationManager.httpRequestBody` - fix would seem to be to set `JsonWriter.serializeNulls` to true after construction.
**Screenshots**
N/A
**Environment(please complete the following information):**
- AppSync SDK Version: 3.1.1
**Device Information (please complete the following information):**
- Device: Simulator
- Android Version: 29
- Specific to simulators: No
**Additional context**
Contributor guide
Research direction
Start at AppSyncOfflineMutationManager.httpRequestBody and inspect how its JsonWriter handles nullable input fields. Reproduce the mutation with nullable set to null, then verify that the request body preserves the explicit null rather than omitting the field.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- api, mobile-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100