Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui) Build entity doesn't exist page for entity profiles #7150

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ private void configureContainerResolvers(final RuntimeWiring.Builder builder) {
.type("Container", typeWiring -> typeWiring
.dataFetcher("relationships", new EntityRelationshipsResultResolver(graphClient))
.dataFetcher("entities", new ContainerEntitiesResolver(entityClient))
.dataFetcher("exists", new EntityExistsResolver(entityService))
.dataFetcher("platform",
new LoadableTypeResolver<>(dataPlatformType,
(env) -> ((Container) env.getSource()).getPlatform().getUrn()))
Expand Down Expand Up @@ -984,6 +985,7 @@ private void configureDatasetResolvers(final RuntimeWiring.Builder builder) {
.dataFetcher("assertions", new EntityAssertionsResolver(entityClient, graphClient))
.dataFetcher("testResults", new TestResultsResolver(entityClient))
.dataFetcher("aspects", new WeaklyTypedAspectsResolver(entityClient, entityRegistry))
.dataFetcher("exists", new EntityExistsResolver(entityService))
.dataFetcher("subTypes", new SubTypesResolver(
this.entityClient,
"dataset",
Expand Down Expand Up @@ -1057,13 +1059,15 @@ private void configureGlossaryTermResolvers(final RuntimeWiring.Builder builder)
.dataFetcher("schemaMetadata", new AspectResolver())
.dataFetcher("parentNodes", new ParentNodesResolver(entityClient))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher("exists", new EntityExistsResolver(entityService))
);
}

private void configureGlossaryNodeResolvers(final RuntimeWiring.Builder builder) {
builder.type("GlossaryNode", typeWiring -> typeWiring
.dataFetcher("parentNodes", new ParentNodesResolver(entityClient))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher("exists", new EntityExistsResolver(entityService))
);
}

Expand Down Expand Up @@ -1148,6 +1152,7 @@ private void configureNotebookResolvers(final RuntimeWiring.Builder builder) {
.dataFetcher("browsePaths", new EntityBrowsePathsResolver(this.notebookType))
.dataFetcher("platform", new LoadableTypeResolver<>(dataPlatformType,
(env) -> ((Notebook) env.getSource()).getPlatform().getUrn()))
.dataFetcher("exists", new EntityExistsResolver(entityService))
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
Expand Down Expand Up @@ -1185,6 +1190,7 @@ private void configureDashboardResolvers(final RuntimeWiring.Builder builder) {
.dataFetcher("usageStats", new DashboardUsageStatsResolver(timeseriesAspectService))
.dataFetcher("statsSummary", new DashboardStatsSummaryResolver(timeseriesAspectService))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher("exists", new EntityExistsResolver(entityService))
);
builder.type("DashboardInfo", typeWiring -> typeWiring
.dataFetcher("charts", new LoadableTypeBatchResolver<>(chartType,
Expand Down Expand Up @@ -1237,6 +1243,7 @@ private void configureChartResolvers(final RuntimeWiring.Builder builder) {
.dataFetcher("parentContainers", new ParentContainersResolver(entityClient))
.dataFetcher("statsSummary", new ChartStatsSummaryResolver(this.timeseriesAspectService))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher("exists", new EntityExistsResolver(entityService))
);
builder.type("ChartInfo", typeWiring -> typeWiring
.dataFetcher("inputs", new LoadableTypeBatchResolver<>(datasetType,
Expand All @@ -1256,7 +1263,9 @@ private void configureTypeResolvers(final RuntimeWiring.Builder builder) {
.filter(graphType -> graphType instanceof EntityType)
.map(graphType -> (EntityType<?, ?>) graphType)
.collect(Collectors.toList())
)))
))
.dataFetcher("exists", new EntityExistsResolver(entityService))
chriscollins3456 marked this conversation as resolved.
Show resolved Hide resolved
)
.type("EntityWithRelationships", typeWiring -> typeWiring
.typeResolver(new EntityInterfaceTypeResolver(loadableTypes.stream()
.filter(graphType -> graphType instanceof EntityType)
Expand Down Expand Up @@ -1314,6 +1323,7 @@ private void configureDataJobResolvers(final RuntimeWiring.Builder builder) {
)
.dataFetcher("runs", new DataJobRunsResolver(entityClient))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher("exists", new EntityExistsResolver(entityService))
)
.type("DataJobInputOutput", typeWiring -> typeWiring
.dataFetcher("inputDatasets", new LoadableTypeBatchResolver<>(datasetType,
Expand Down Expand Up @@ -1342,6 +1352,7 @@ private void configureDataFlowResolvers(final RuntimeWiring.Builder builder) {
.dataFetcher("lineage", new EntityLineageResultResolver(siblingGraphService))
.dataFetcher("platform", new LoadableTypeResolver<>(dataPlatformType,
(env) -> ((DataFlow) env.getSource()).getPlatform().getUrn()))
.dataFetcher("exists", new EntityExistsResolver(entityService))
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
Expand All @@ -1361,6 +1372,7 @@ private void configureMLFeatureTableResolvers(final RuntimeWiring.Builder builde
.dataFetcher("relationships", new EntityRelationshipsResultResolver(graphClient))
.dataFetcher("browsePaths", new EntityBrowsePathsResolver(this.mlFeatureTableType))
.dataFetcher("lineage", new EntityLineageResultResolver(siblingGraphService))
.dataFetcher("exists", new EntityExistsResolver(entityService))
.dataFetcher("platform",
new LoadableTypeResolver<>(dataPlatformType,
(env) -> ((MLFeatureTable) env.getSource()).getPlatform().getUrn()))
Expand Down Expand Up @@ -1416,6 +1428,7 @@ private void configureMLFeatureTableResolvers(final RuntimeWiring.Builder builde
.dataFetcher("relationships", new EntityRelationshipsResultResolver(graphClient))
.dataFetcher("browsePaths", new EntityBrowsePathsResolver(this.mlModelType))
.dataFetcher("lineage", new EntityLineageResultResolver(siblingGraphService))
.dataFetcher("exists", new EntityExistsResolver(entityService))
.dataFetcher("platform", new LoadableTypeResolver<>(dataPlatformType,
(env) -> ((MLModel) env.getSource()).getPlatform().getUrn()))
.dataFetcher("dataPlatformInstance",
Expand Down Expand Up @@ -1446,6 +1459,7 @@ private void configureMLFeatureTableResolvers(final RuntimeWiring.Builder builde
.dataFetcher("platform", new LoadableTypeResolver<>(dataPlatformType,
(env) -> ((MLModelGroup) env.getSource()).getPlatform().getUrn())
)
.dataFetcher("exists", new EntityExistsResolver(entityService))
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
Expand All @@ -1457,6 +1471,7 @@ private void configureMLFeatureTableResolvers(final RuntimeWiring.Builder builde
.type("MLFeature", typeWiring -> typeWiring
.dataFetcher("relationships", new EntityRelationshipsResultResolver(graphClient))
.dataFetcher("lineage", new EntityLineageResultResolver(siblingGraphService))
.dataFetcher("exists", new EntityExistsResolver(entityService))
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
Expand All @@ -1468,6 +1483,7 @@ private void configureMLFeatureTableResolvers(final RuntimeWiring.Builder builde
.type("MLPrimaryKey", typeWiring -> typeWiring
.dataFetcher("relationships", new EntityRelationshipsResultResolver(graphClient))
.dataFetcher("lineage", new EntityLineageResultResolver(siblingGraphService))
.dataFetcher("exists", new EntityExistsResolver(entityService))
.dataFetcher("dataPlatformInstance",
new LoadableTypeResolver<>(dataPlatformInstanceType,
(env) -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.linkedin.datahub.graphql.resolvers.entity;

import com.linkedin.common.urn.Urn;
import com.linkedin.datahub.graphql.generated.Entity;
import com.linkedin.metadata.entity.EntityService;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
Expand All @@ -22,15 +23,19 @@ public EntityExistsResolver(final EntityService entityService) {

@Override
public CompletableFuture<Boolean> get(final DataFetchingEnvironment environment) throws Exception {
final String entityUrnString = bindArgument(environment.getArgument("urn"), String.class);
String entityUrnString = bindArgument(environment.getArgument("urn"), String.class);
// resolver can be used as its own endpoint or when hydrating an entity
if (entityUrnString == null && environment.getSource() != null) {
entityUrnString = ((Entity) environment.getSource()).getUrn();
}
Objects.requireNonNull(entityUrnString, "Entity urn must not be null!");

Urn entityUrn = Urn.createFromString(entityUrnString);
final Urn entityUrn = Urn.createFromString(entityUrnString);
return CompletableFuture.supplyAsync(() -> {
try {
return _entityService.exists(entityUrn);
} catch (Exception e) {
throw new RuntimeException(String.format("Failed to check whether entity %s exists", entityUrnString));
throw new RuntimeException(String.format("Failed to check whether entity %s exists", entityUrn.toString()));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ public Dataset apply(@Nonnull final EntityResponse entityResponse) {
Long lastIngested = SystemMetadataUtils.getLastIngested(aspectMap);
result.setLastIngested(lastIngested);

System.out.println("~~~~~~~~~~~~~~~~~~~~~~HERE~~~~~~~~~~~~~~~");
chriscollins3456 marked this conversation as resolved.
Show resolved Hide resolved
System.out.println(entityResponse);
System.out.println("..........");
System.out.println(aspectMap);
System.out.println("..........");
System.out.println("~~~~~~~~~~~~~~~~~~~~~~HERE~~~~~~~~~~~~~~~");

MappingHelper<Dataset> mappingHelper = new MappingHelper<>(aspectMap, result);
mappingHelper.mapToResult(DATASET_KEY_ASPECT_NAME, this::mapDatasetKey);
mappingHelper.mapToResult(DATASET_PROPERTIES_ASPECT_NAME, (entity, dataMap) -> this.mapDatasetProperties(entity, dataMap, entityUrn));
Expand Down Expand Up @@ -110,6 +117,12 @@ public Dataset apply(@Nonnull final EntityResponse entityResponse) {

private void mapDatasetKey(@Nonnull Dataset dataset, @Nonnull DataMap dataMap) {
final DatasetKey gmsKey = new DatasetKey(dataMap);
System.out.println("~~~~~~~~~~~~~~~~~~~~~~NOW~~~~~~~~~~~~~~~");
System.out.println(gmsKey);
chriscollins3456 marked this conversation as resolved.
Show resolved Hide resolved
System.out.println("........");
System.out.println(gmsKey.getName());
System.out.println("~~~~~~~~~~~~~~~~~~~~~~NOW~~~~~~~~~~~~~~~");

dataset.setName(gmsKey.getName());
dataset.setOrigin(FabricType.valueOf(gmsKey.getOrigin().toString()));
dataset.setPlatform(DataPlatform.builder()
Expand Down
70 changes: 70 additions & 0 deletions datahub-graphql-core/src/main/resources/entity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,11 @@ type Dataset implements EntityWithRelationships & Entity & BrowsableEntity {
Privileges given to a user relevant to this entity
"""
privileges: EntityPrivileges

"""
Whether or not this entity exists in the database
chriscollins3456 marked this conversation as resolved.
Show resolved Hide resolved
"""
exists: Boolean
}

type FineGrainedLineage {
Expand Down Expand Up @@ -1585,6 +1590,11 @@ type GlossaryTerm implements Entity {
Privileges given to a user relevant to this entity
"""
privileges: EntityPrivileges

"""
Whether or not this entity exists in the database
"""
exists: Boolean
}

"""
Expand Down Expand Up @@ -1717,6 +1727,11 @@ type GlossaryNode implements Entity {
Privileges given to a user relevant to this entity
"""
privileges: EntityPrivileges

"""
Whether or not this entity exists in the database
"""
exists: Boolean
}

"""
Expand Down Expand Up @@ -2082,6 +2097,11 @@ type Container implements Entity {
Status metadata of the container
"""
status: Status

"""
Whether or not this entity exists in the database
"""
exists: Boolean
}

"""
Expand Down Expand Up @@ -4215,6 +4235,11 @@ type Notebook implements Entity & BrowsableEntity {
The browse paths corresponding to the Notebook. If no Browse Paths have been generated before, this will be null.
"""
browsePaths: [BrowsePath!]

"""
Whether or not this entity exists in the database
"""
exists: Boolean
}

"""
Expand Down Expand Up @@ -4525,6 +4550,11 @@ type Dashboard implements EntityWithRelationships & Entity & BrowsableEntity {
Privileges given to a user relevant to this entity
"""
privileges: EntityPrivileges

"""
Whether or not this entity exists in the database
"""
exists: Boolean
}

"""
Expand Down Expand Up @@ -4820,6 +4850,11 @@ type Chart implements EntityWithRelationships & Entity & BrowsableEntity {
Privileges given to a user relevant to this entity
"""
privileges: EntityPrivileges

"""
Whether or not this entity exists in the database
"""
exists: Boolean
}

"""
Expand Down Expand Up @@ -5167,6 +5202,11 @@ type DataFlow implements EntityWithRelationships & Entity & BrowsableEntity {
Standardized platform urn where the datflow is defined
"""
platform: DataPlatform!

"""
Whether or not this entity exists in the database
"""
exists: Boolean
}

"""
Expand Down Expand Up @@ -5354,6 +5394,11 @@ type DataJob implements EntityWithRelationships & Entity & BrowsableEntity {
Privileges given to a user relevant to this entity
"""
privileges: EntityPrivileges

"""
Whether or not this entity exists in the database
"""
exists: Boolean
}

"""
Expand Down Expand Up @@ -8191,6 +8236,11 @@ type MLModel implements EntityWithRelationships & Entity & BrowsableEntity {
An additional set of of read write properties
"""
editableProperties: MLModelEditableProperties

"""
Whether or not this entity exists in the database
"""
exists: Boolean
}

"""
Expand Down Expand Up @@ -8292,6 +8342,11 @@ type MLModelGroup implements EntityWithRelationships & Entity & BrowsableEntity
An additional set of of read write properties
"""
editableProperties: MLModelGroupEditableProperties

"""
Whether or not this entity exists in the database
"""
exists: Boolean
}

type MLModelGroupProperties {
Expand Down Expand Up @@ -8406,6 +8461,11 @@ type MLFeature implements EntityWithRelationships & Entity {
An additional set of of read write properties
"""
editableProperties: MLFeatureEditableProperties

"""
Whether or not this entity exists in the database
"""
exists: Boolean
}

type MLHyperParam {
Expand Down Expand Up @@ -8570,6 +8630,11 @@ type MLPrimaryKey implements EntityWithRelationships & Entity {
An additional set of of read write properties
"""
editableProperties: MLPrimaryKeyEditableProperties

"""
Whether or not this entity exists in the database
"""
exists: Boolean
}

type MLPrimaryKeyProperties {
Expand Down Expand Up @@ -8687,6 +8752,11 @@ type MLFeatureTable implements EntityWithRelationships & Entity & BrowsableEntit
An additional set of of read write properties
"""
editableProperties: MLFeatureTableEditableProperties

"""
Whether or not this entity exists in the database
"""
exists: Boolean
}

type MLFeatureTableEditableProperties {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LoadingOutlined } from '@ant-design/icons';
import { QueryHookOptions, QueryResult } from '@apollo/client';
import { Divider } from 'antd';
import { Divider, Result } from 'antd';
import React from 'react';
import styled from 'styled-components';
import { EntityType, Exact } from '../../../../types.generated';
Expand Down Expand Up @@ -49,6 +49,10 @@ export default function EmbeddedProfile<T>({ urn, entityType, getOverridePropert
const { entityData, dataPossiblyCombinedWithSiblings, dataNotCombinedWithSiblings, loading, refetch } =
useGetDataForProfile({ urn, entityType, useEntityQuery, getOverrideProperties });

if (entityData?.exists === false) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome!

return <Result status="404" title="Not Found" subTitle="Sorry, we are unable to find this entity in DataHub" />;
}

return (
<EntityContext.Provider
value={{
Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/app/entity/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export type GenericEntityProperties = {
fineGrainedLineages?: Maybe<FineGrainedLineage[]>;
privileges?: Maybe<EntityPrivileges>;
embed?: Maybe<Embed>;
exists?: boolean;
};

export type GenericEntityUpdate = {
Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/graphql/chart.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ query getChart($urn: String!) {
chart(urn: $urn) {
urn
type
exists
chriscollins3456 marked this conversation as resolved.
Show resolved Hide resolved
lastIngested
tool
chartId
Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/graphql/container.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
query getContainer($urn: String!) {
container(urn: $urn) {
urn
exists
lastIngested
platform {
...platformFields
Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/graphql/dataFlow.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
fragment dataFlowFields on DataFlow {
urn
type
exists
jjoyce0510 marked this conversation as resolved.
Show resolved Hide resolved
lastIngested
orchestrator
flowId
Expand Down
Loading