Closed
Description
When sending a mutation with a zero-length collection as a nested field, shouldn't it be extracted as a zero-length list instead of null?
I tried adding a test to org.springframework.graphql.data.method.annotation.support.GraphQlArgumentInitializerTests. It fails since "items" is extracted as null.
@Test
void shouldInstantiateEmptyNestedBeanLists() throws Exception {
String payload = "{\"nestedList\": { \"items\": [ ] } }";
DataFetchingEnvironment environment = initEnvironment(payload);
Object result = initializer.initializeArgument(
environment, "nestedList", ResolvableType.forClass(NestedList.class));
assertThat(result).isNotNull().isInstanceOf(NestedList.class);
assertThat(((NestedList) result).getItems()).hasSize(0);
}
Is this correct behavior or should it be improved?