Skip to content

Commit

Permalink
Revert "fix(gql): removing data platform caching in gql (#2947)" (#2956)
Browse files Browse the repository at this point in the history
This reverts commit 49093ea.
  • Loading branch information
gabe-lyons authored Jul 26, 2021
1 parent f82ea3a commit 79c956a
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
public class DataPlatformType implements EntityType<DataPlatform> {

private final DataPlatforms _dataPlatformsClient;
private Map<String, DataPlatform> _urnToPlatform;

public DataPlatformType(final DataPlatforms dataPlatformsClient) {
_dataPlatformsClient = dataPlatformsClient;
Expand All @@ -29,12 +30,13 @@ public Class<DataPlatform> objectClass() {
@Override
public List<DataFetcherResult<DataPlatform>> batchLoad(final List<String> urns, final QueryContext context) {
try {
Map<String, DataPlatform> urnToPlatform = _dataPlatformsClient.getAllPlatforms()
.stream()
.map(DataPlatformMapper::map)
.collect(Collectors.toMap(DataPlatform::getUrn, platform -> platform));
if (_urnToPlatform == null) {
_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) {
Expand Down

0 comments on commit 79c956a

Please sign in to comment.