Skip to content

No ability to serlialize null input fields #383

@tbartley

Description

@tbartley

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions