awslabs / aws-mobile-appsync-sdk-android

Android SDK for AWS AppSync.
https://docs.amplify.aws/sdk/api/graphql/q/platform/android/
Apache License 2.0
105 stars 58 forks source link

No ability to serlialize null input fields #383

Open tbartley opened 2 years ago

tbartley commented 2 years ago

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):

Device Information (please complete the following information):

Additional context