From 67953c7725b29874a9433282e14d89aaf2019a2a Mon Sep 17 00:00:00 2001 From: Gabe Lyons Date: Thu, 11 Aug 2022 09:41:39 -0700 Subject: [PATCH] do not require sources in graphql --- .../datahub/graphql/GmsGraphQLEngine.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/GmsGraphQLEngine.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/GmsGraphQLEngine.java index d9bc2fe1a864a..960ba52b9aa5c 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/GmsGraphQLEngine.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/GmsGraphQLEngine.java @@ -1247,16 +1247,26 @@ private void configureMLFeatureTableResolvers(final RuntimeWiring.Builder builde ) .type("MLFeatureProperties", typeWiring -> typeWiring .dataFetcher("sources", new LoadableTypeBatchResolver<>(datasetType, - (env) -> ((MLFeatureProperties) env.getSource()).getSources().stream() - .map(datasetType.getKeyProvider()) - .collect(Collectors.toList())) + (env) -> { + if (((MLFeatureProperties) env.getSource()).getSources() == null) { + return Collections.emptyList(); + } + return ((MLFeatureProperties) env.getSource()).getSources().stream() + .map(datasetType.getKeyProvider()) + .collect(Collectors.toList()); + }) ) ) .type("MLPrimaryKeyProperties", typeWiring -> typeWiring .dataFetcher("sources", new LoadableTypeBatchResolver<>(datasetType, - (env) -> ((MLPrimaryKeyProperties) env.getSource()).getSources().stream() + (env) -> { + if (((MLPrimaryKeyProperties) env.getSource()).getSources() == null) { + return Collections.emptyList(); + } + return ((MLPrimaryKeyProperties) env.getSource()).getSources().stream() .map(datasetType.getKeyProvider()) - .collect(Collectors.toList())) + .collect(Collectors.toList()); + }) ) ) .type("MLModel", typeWiring -> typeWiring