You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MappedBatchLoader is a great addition to the data loading architecture. Sadly, we can't use it in many cases. Frequently we data load lists like so:
type Parent {
id: String!
children: [Child!]! # lazy-loaded via data loader, can not be null
}
When data loading children the return type of the mapped batch loading function is Map<String, List<Child>>. When a key is not present in the map, DataLoaderHelper::invokeMapBatchLoader substitutes null. However, in this case outlined above it should instead substitute an empty list.
I propose adding an additional data loader option that would let us set this default value to an arbitrary value. Another solution that might suffice would be the helper first testing whether the loadResult is a Collection and if so, substituting an empty collection by default.
The text was updated successfully, but these errors were encountered:
vojtapol
changed the title
Allow providing default value for missing key in MappedBatchLoader result
Allow providing custom default value for missing key in MappedBatchLoader result
Jan 24, 2019
MappedBatchLoader is a great addition to the data loading architecture. Sadly, we can't use it in many cases. Frequently we data load lists like so:
When data loading
children
the return type of the mapped batch loading function isMap<String, List<Child>>
. When a key is not present in the map,DataLoaderHelper::invokeMapBatchLoader
substitutesnull
. However, in this case outlined above it should instead substitute an empty list.I propose adding an additional data loader option that would let us set this default value to an arbitrary value. Another solution that might suffice would be the helper first testing whether the
loadResult
is aCollection
and if so, substituting an empty collection by default.The text was updated successfully, but these errors were encountered: