Skip to content

Commit dca2bd0

Browse files
fix(api) serialize nulls on requests to support setting fields to null (#1091)
1 parent 47de6e5 commit dca2bd0

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

aws-api-appsync/src/main/java/com/amplifyframework/util/GsonFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ private static Gson create() {
5353
GsonResponseAdapters.register(builder);
5454
ModelWithMetadataAdapter.register(builder);
5555
SerializedModelAdapter.register(builder);
56+
builder.serializeNulls();
5657
return builder.create();
5758
}
5859
}

aws-datastore/src/test/java/com/amplifyframework/datastore/appsync/AppSyncClientTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public void validateUpdateMutationWithDates() throws JSONException, AmplifyExcep
165165
.time(new Temporal.Time("01:22:33"))
166166
.timestamp(new Temporal.Timestamp(1234567890000L, TimeUnit.MILLISECONDS))
167167
.build();
168-
endpoint.update(meeting, ModelSchema.fromModelClass(Meeting.class), null, response -> { }, error -> { });
168+
endpoint.update(meeting, ModelSchema.fromModelClass(Meeting.class), 1, response -> { }, error -> { });
169169

170170
// Now, capture the request argument on API, so we can see what was passed.
171171
ArgumentCaptor<GraphQLRequest<ModelWithMetadata<Meeting>>> requestCaptor =

aws-datastore/src/test/resources/update-blog-owner-with-predicate.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"input": {
2323
"_version" : 42,
2424
"id" : "926d7ee8-4ea5-40c0-8e62-3fb80b2a2edd",
25-
"name" : "John Doe"
25+
"name" : "John Doe",
26+
"wea" : null
2627
}
2728
}
2829
}

aws-datastore/src/test/resources/update-meeting.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,16 @@
1111
timestamp
1212
}
1313
}
14-
","variables":{"input":{"date":"2001-02-03","dateTime":"2001-02-03T01:30:15Z","name":"meeting1","id":"45a5f600-8aa8-41ac-a529-aed75036f5be","time":"01:22:33","timestamp":1234567890}}}
14+
",
15+
"variables": {
16+
"input": {
17+
"date": "2001-02-03",
18+
"dateTime": "2001-02-03T01:30:15Z",
19+
"name": "meeting1",
20+
"id": "45a5f600-8aa8-41ac-a529-aed75036f5be",
21+
"time": "01:22:33",
22+
"timestamp": 1234567890,
23+
"_version": 1
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)