Consider below query:
const fetchItemsQuery = `query(
$paginationPageSize: Int!
$paginationPageNumber: Int!
$searchByNameRequest: String
$categoryID: String
) {
getItems(
paginationPageSize: $paginationPageSize
paginationPageNumber: $paginationPageNumber
searchByNameRequest: $searchByNameRequest
categoryID: $categoryID
) {
// ...
}
};
If to submit it from client side with variables:
{
paginationPageSize: 20,
paginationPageNumber: 1
}
in AWS App Sync logs, it reads:
{
paginationPageSize: 20,
paginationPageNumber: 1,
searchByNameRequest: null,
categoryID: null
}
I checked the request payload from browser - no nulls, just
{
paginationPageSize: 20,
paginationPageNumber: 1
}
So the cause is not in frontend side.
I found out that the null substitution occurring in request resolving template:
{
"version" : "2017-02-28",
"operation": "Invoke",
"payload": {
"field": "listProduct",
"arguments": $util.toJson($context.args) // <- here
}
}
$util.toJson uses Apache Velocity.
Can I avoid $util.toJson($context.args) will substitute the nulls in my request variables?
Important: the solution should not touch the explicitly submitted nulls .