fix(gql): removing data platform caching in gql (#2947)

This commit is contained in:
Gabe Lyons 2021-07-25 21:16:49 -07:00 committed by GitHub
parent 6135eed757
commit 49093ea1ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,7 +16,6 @@ import java.util.stream.Collectors;
public class DataPlatformType implements EntityType<DataPlatform> {
private final DataPlatforms _dataPlatformsClient;
private Map<String, DataPlatform> _urnToPlatform;
public DataPlatformType(final DataPlatforms dataPlatformsClient) {
_dataPlatformsClient = dataPlatformsClient;
@ -30,13 +29,12 @@ public class DataPlatformType implements EntityType<DataPlatform> {
@Override
public List<DataFetcherResult<DataPlatform>> batchLoad(final List<String> urns, final QueryContext context) {
try {
if (_urnToPlatform == null) {
_urnToPlatform = _dataPlatformsClient.getAllPlatforms().stream()
.map(DataPlatformMapper::map)
.collect(Collectors.toMap(DataPlatform::getUrn, platform -> platform));
}
Map<String, DataPlatform> urnToPlatform = _dataPlatformsClient.getAllPlatforms()
.stream()
.map(DataPlatformMapper::map)
.collect(Collectors.toMap(DataPlatform::getUrn, platform -> platform));
return urns.stream()
.map(key -> _urnToPlatform.containsKey(key) ? _urnToPlatform.get(key) : getUnknownDataPlatform(key))
.map(key -> urnToPlatform.containsKey(key) ? urnToPlatform.get(key) : getUnknownDataPlatform(key))
.map(dataPlatform -> DataFetcherResult.<DataPlatform>newResult().data(dataPlatform).build())
.collect(Collectors.toList());
} catch (Exception e) {