In RecordLayer.java:
.map(dynamicMessage -> {
Map<String, Object> results = new HashMap<>();
dynamicMessage.getAllFields().forEach((key, value) -> results.put(key.getName(), value));
return results;
We are doing this because:
Once we have a list of ProductDTO objects we typically don’t need specialised data fetchers on each field. graphql-java ships with a smart graphql.schema.PropertyDataFetcher that knows how to follow POJO patterns based on the field name. In the example above there is a name field and hence it will try to look for a public String getName() POJO method to get the data.
https://www.graphql-java.com/documentation/v11/data-fetching/
In RecordLayer.java:
We are doing this because:
https://www.graphql-java.com/documentation/v11/data-fetching/