Skip to content

Commit

Permalink
Merge branch 'datahub-project:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
anshbansal authored Feb 16, 2024
2 parents 0155080 + e4bc915 commit e8cda87
Show file tree
Hide file tree
Showing 144 changed files with 6,987 additions and 316 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ project.ext.externalDependency = [
'elasticSearchRest': 'org.opensearch.client:opensearch-rest-high-level-client:' + elasticsearchVersion,
'elasticSearchJava': 'org.opensearch.client:opensearch-java:2.6.0',
'findbugsAnnotations': 'com.google.code.findbugs:annotations:3.0.1',
'graphqlJava': 'com.graphql-java:graphql-java:19.5',
'graphqlJavaScalars': 'com.graphql-java:graphql-java-extended-scalars:19.1',
'graphqlJava': 'com.graphql-java:graphql-java:21.3',
'graphqlJavaScalars': 'com.graphql-java:graphql-java-extended-scalars:21.0',
'gson': 'com.google.code.gson:gson:2.8.9',
'guice': 'com.google.inject:guice:7.0.0',
'guice4': 'com.google.inject:guice:4.2.3', // Used for frontend while still on old Play version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ private Constants() {}
public static final String LINEAGE_SCHEMA_FILE = "lineage.graphql";
public static final String PROPERTIES_SCHEMA_FILE = "properties.graphql";
public static final String FORMS_SCHEMA_FILE = "forms.graphql";
public static final String INCIDENTS_SCHEMA_FILE = "incident.graphql";
public static final String BROWSE_PATH_DELIMITER = "/";
public static final String BROWSE_PATH_V2_DELIMITER = "␟";
public static final String VERSION_STAMP_FIELD_NAME = "versionStamp";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import com.linkedin.datahub.graphql.generated.GlossaryNode;
import com.linkedin.datahub.graphql.generated.GlossaryTerm;
import com.linkedin.datahub.graphql.generated.GlossaryTermAssociation;
import com.linkedin.datahub.graphql.generated.IncidentSource;
import com.linkedin.datahub.graphql.generated.IngestionSource;
import com.linkedin.datahub.graphql.generated.InstitutionalMemoryMetadata;
import com.linkedin.datahub.graphql.generated.LineageRelationship;
Expand All @@ -89,6 +90,7 @@
import com.linkedin.datahub.graphql.generated.ParentDomainsResult;
import com.linkedin.datahub.graphql.generated.PolicyMatchCriterionValue;
import com.linkedin.datahub.graphql.generated.QueryEntity;
import com.linkedin.datahub.graphql.generated.QueryProperties;
import com.linkedin.datahub.graphql.generated.QuerySubject;
import com.linkedin.datahub.graphql.generated.QuickFilter;
import com.linkedin.datahub.graphql.generated.RecommendationContent;
Expand Down Expand Up @@ -125,7 +127,6 @@
import com.linkedin.datahub.graphql.resolvers.dataproduct.DeleteDataProductResolver;
import com.linkedin.datahub.graphql.resolvers.dataproduct.ListDataProductAssetsResolver;
import com.linkedin.datahub.graphql.resolvers.dataproduct.UpdateDataProductResolver;
import com.linkedin.datahub.graphql.resolvers.dataset.DatasetHealthResolver;
import com.linkedin.datahub.graphql.resolvers.dataset.DatasetStatsSummaryResolver;
import com.linkedin.datahub.graphql.resolvers.dataset.DatasetUsageStatsResolver;
import com.linkedin.datahub.graphql.resolvers.deprecation.UpdateDeprecationResolver;
Expand Down Expand Up @@ -158,6 +159,10 @@
import com.linkedin.datahub.graphql.resolvers.group.ListGroupsResolver;
import com.linkedin.datahub.graphql.resolvers.group.RemoveGroupMembersResolver;
import com.linkedin.datahub.graphql.resolvers.group.RemoveGroupResolver;
import com.linkedin.datahub.graphql.resolvers.health.EntityHealthResolver;
import com.linkedin.datahub.graphql.resolvers.incident.EntityIncidentsResolver;
import com.linkedin.datahub.graphql.resolvers.incident.RaiseIncidentResolver;
import com.linkedin.datahub.graphql.resolvers.incident.UpdateIncidentStatusResolver;
import com.linkedin.datahub.graphql.resolvers.ingest.execution.CancelIngestionExecutionRequestResolver;
import com.linkedin.datahub.graphql.resolvers.ingest.execution.CreateIngestionExecutionRequestResolver;
import com.linkedin.datahub.graphql.resolvers.ingest.execution.CreateTestConnectionRequestResolver;
Expand Down Expand Up @@ -305,6 +310,7 @@
import com.linkedin.datahub.graphql.types.form.FormType;
import com.linkedin.datahub.graphql.types.glossary.GlossaryNodeType;
import com.linkedin.datahub.graphql.types.glossary.GlossaryTermType;
import com.linkedin.datahub.graphql.types.incident.IncidentType;
import com.linkedin.datahub.graphql.types.mlmodel.MLFeatureTableType;
import com.linkedin.datahub.graphql.types.mlmodel.MLFeatureType;
import com.linkedin.datahub.graphql.types.mlmodel.MLModelGroupType;
Expand Down Expand Up @@ -460,6 +466,7 @@ public class GmsGraphQLEngine {
private final DataTypeType dataTypeType;
private final EntityTypeType entityTypeType;
private final FormType formType;
private final IncidentType incidentType;

private final int graphQLQueryComplexityLimit;
private final int graphQLQueryDepthLimit;
Expand Down Expand Up @@ -567,6 +574,7 @@ public GmsGraphQLEngine(final GmsGraphQLEngineArgs args) {
this.dataTypeType = new DataTypeType(entityClient);
this.entityTypeType = new EntityTypeType(entityClient);
this.formType = new FormType(entityClient);
this.incidentType = new IncidentType(entityClient);

this.graphQLQueryComplexityLimit = args.graphQLQueryComplexityLimit;
this.graphQLQueryDepthLimit = args.graphQLQueryDepthLimit;
Expand Down Expand Up @@ -609,7 +617,8 @@ public GmsGraphQLEngine(final GmsGraphQLEngineArgs args) {
structuredPropertyType,
dataTypeType,
entityTypeType,
formType);
formType,
incidentType);
this.loadableTypes = new ArrayList<>(entityTypes);
// Extend loadable types with types from the plugins
// This allows us to offer search and browse capabilities out of the box for those types
Expand Down Expand Up @@ -698,6 +707,7 @@ public void configureRuntimeWiring(final RuntimeWiring.Builder builder) {
configurePluginResolvers(builder);
configureStructuredPropertyResolvers(builder);
configureFormResolvers(builder);
configureIncidentResolvers(builder);
}

private void configureOrganisationRoleResolvers(RuntimeWiring.Builder builder) {
Expand Down Expand Up @@ -747,7 +757,8 @@ public GraphQLEngine.Builder builder() {
.addSchema(fileBasedSchema(STEPS_SCHEMA_FILE))
.addSchema(fileBasedSchema(LINEAGE_SCHEMA_FILE))
.addSchema(fileBasedSchema(PROPERTIES_SCHEMA_FILE))
.addSchema(fileBasedSchema(FORMS_SCHEMA_FILE));
.addSchema(fileBasedSchema(FORMS_SCHEMA_FILE))
.addSchema(fileBasedSchema(INCIDENTS_SCHEMA_FILE));

for (GmsGraphQLPlugin plugin : this.graphQLPlugins) {
List<String> pluginSchemaFiles = plugin.getSchemaFiles();
Expand Down Expand Up @@ -1202,7 +1213,11 @@ private void configureMutationResolvers(final RuntimeWiring.Builder builder) {
"createDynamicFormAssignment",
new CreateDynamicFormAssignmentResolver(this.formService))
.dataFetcher(
"verifyForm", new VerifyFormResolver(this.formService, this.groupService)));
"verifyForm", new VerifyFormResolver(this.formService, this.groupService))
.dataFetcher("raiseIncident", new RaiseIncidentResolver(this.entityClient))
.dataFetcher(
"updateIncidentStatus",
new UpdateIncidentStatusResolver(this.entityClient, this.entityService)));
}

private void configureGenericEntityResolvers(final RuntimeWiring.Builder builder) {
Expand Down Expand Up @@ -1485,7 +1500,12 @@ private void configureDatasetResolvers(final RuntimeWiring.Builder builder) {
.dataFetcher("usageStats", new DatasetUsageStatsResolver(this.usageClient))
.dataFetcher("statsSummary", new DatasetStatsSummaryResolver(this.usageClient))
.dataFetcher(
"health", new DatasetHealthResolver(graphClient, timeseriesAspectService))
"health",
new EntityHealthResolver(
entityClient,
graphClient,
timeseriesAspectService,
new EntityHealthResolver.Config(true, true)))
.dataFetcher("schemaMetadata", new AspectResolver())
.dataFetcher(
"assertions", new EntityAssertionsResolver(entityClient, graphClient))
Expand Down Expand Up @@ -1834,7 +1854,14 @@ private void configureDashboardResolvers(final RuntimeWiring.Builder builder) {
.dataFetcher(
"statsSummary", new DashboardStatsSummaryResolver(timeseriesAspectService))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher("exists", new EntityExistsResolver(entityService)));
.dataFetcher("exists", new EntityExistsResolver(entityService))
.dataFetcher(
"health",
new EntityHealthResolver(
entityClient,
graphClient,
timeseriesAspectService,
new EntityHealthResolver.Config(false, true))));
builder.type(
"DashboardInfo",
typeWiring ->
Expand Down Expand Up @@ -1951,7 +1978,14 @@ private void configureChartResolvers(final RuntimeWiring.Builder builder) {
.dataFetcher(
"statsSummary", new ChartStatsSummaryResolver(this.timeseriesAspectService))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher("exists", new EntityExistsResolver(entityService)));
.dataFetcher("exists", new EntityExistsResolver(entityService))
.dataFetcher(
"health",
new EntityHealthResolver(
entityClient,
graphClient,
timeseriesAspectService,
new EntityHealthResolver.Config(false, true))));
builder.type(
"ChartInfo",
typeWiring ->
Expand Down Expand Up @@ -2056,7 +2090,14 @@ private void configureDataJobResolvers(final RuntimeWiring.Builder builder) {
}))
.dataFetcher("runs", new DataJobRunsResolver(entityClient))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher("exists", new EntityExistsResolver(entityService)))
.dataFetcher("exists", new EntityExistsResolver(entityService))
.dataFetcher(
"health",
new EntityHealthResolver(
entityClient,
graphClient,
timeseriesAspectService,
new EntityHealthResolver.Config(false, true))))
.type(
"DataJobInputOutput",
typeWiring ->
Expand Down Expand Up @@ -2119,7 +2160,14 @@ private void configureDataFlowResolvers(final RuntimeWiring.Builder builder) {
return dataFlow.getDataPlatformInstance() != null
? dataFlow.getDataPlatformInstance().getUrn()
: null;
})));
}))
.dataFetcher(
"health",
new EntityHealthResolver(
entityClient,
graphClient,
timeseriesAspectService,
new EntityHealthResolver.Config(false, true))));
}

/**
Expand Down Expand Up @@ -2536,9 +2584,27 @@ private void configureQueryEntityResolvers(final RuntimeWiring.Builder builder)
builder
.type(
"QueryEntity",
typeWiring ->
typeWiring
.dataFetcher(
"relationships", new EntityRelationshipsResultResolver(graphClient))
.dataFetcher(
"platform",
new LoadableTypeResolver<>(
dataPlatformType,
(env) -> {
final QueryEntity query = env.getSource();
return query.getPlatform() != null
? query.getPlatform().getUrn()
: null;
})))
.type(
"QueryProperties",
typeWiring ->
typeWiring.dataFetcher(
"relationships", new EntityRelationshipsResultResolver(graphClient)))
"origin",
new EntityTypeResolver(
entityTypes, (env) -> ((QueryProperties) env.getSource()).getOrigin())))
.type(
"ListQueriesResult",
typeWiring ->
Expand Down Expand Up @@ -2660,4 +2726,35 @@ private void configureIngestionSourceResolvers(final RuntimeWiring.Builder build
: null;
})));
}

private void configureIncidentResolvers(final RuntimeWiring.Builder builder) {
builder.type(
"Incident",
typeWiring ->
typeWiring.dataFetcher(
"relationships", new EntityRelationshipsResultResolver(graphClient)));
builder.type(
"IncidentSource",
typeWiring ->
typeWiring.dataFetcher(
"source",
new LoadableTypeResolver<>(
this.assertionType,
(env) -> {
final IncidentSource incidentSource = env.getSource();
return incidentSource.getSource() != null
? incidentSource.getSource().getUrn()
: null;
})));

// Add incidents attribute to all entities that support it
final List<String> entitiesWithIncidents =
ImmutableList.of("Dataset", "DataJob", "DataFlow", "Dashboard", "Chart");
for (String entity : entitiesWithIncidents) {
builder.type(
entity,
typeWiring ->
typeWiring.dataFetcher("incidents", new EntityIncidentsResolver(entityClient)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import graphql.execution.DataFetcherExceptionHandlerResult;
import graphql.execution.ResultPath;
import graphql.language.SourceLocation;
import java.util.concurrent.CompletableFuture;
import lombok.extern.slf4j.Slf4j;

@PublicApi
Expand All @@ -15,7 +16,7 @@ public class DataHubDataFetcherExceptionHandler implements DataFetcherExceptionH
private static final String DEFAULT_ERROR_MESSAGE = "An unknown error occurred.";

@Override
public DataFetcherExceptionHandlerResult onException(
public CompletableFuture<DataFetcherExceptionHandlerResult> handleException(
DataFetcherExceptionHandlerParameters handlerParameters) {
Throwable exception = handlerParameters.getException();
SourceLocation sourceLocation = handlerParameters.getSourceLocation();
Expand Down Expand Up @@ -44,7 +45,8 @@ public DataFetcherExceptionHandlerResult onException(
log.error("Failed to execute", exception);
}
DataHubGraphQLError error = new DataHubGraphQLError(message, path, sourceLocation, errorCode);
return DataFetcherExceptionHandlerResult.newResult().error(error).build();
return CompletableFuture.completedFuture(
DataFetcherExceptionHandlerResult.newResult().error(error).build());
}

<T extends Throwable> T findFirstThrowableCauseOfClass(Throwable throwable, Class<T> clazz) {
Expand Down
Loading

0 comments on commit e8cda87

Please sign in to comment.