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

fix(glossary) Improve business glossary loading performance #6208

Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions datahub-web-react/src/app/entity/glossaryNode/ChildrenTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ function ChildrenTab() {
const { entityData } = useEntityData();
const entityRegistry = useEntityRegistry();

if (!entityData) return <></>;

const childNodes = entityData?.children?.relationships
.filter((child) => child.entity?.type === EntityType.GlossaryNode)
.sort((nodeA, nodeB) => sortGlossaryNodes(entityRegistry, nodeA.entity, nodeB.entity))
Expand Down
60 changes: 40 additions & 20 deletions datahub-web-react/src/app/glossary/GlossaryBrowser/NodeItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FolderOutlined, RightOutlined, DownOutlined } from '@ant-design/icons';
import { FolderOutlined, RightOutlined, DownOutlined, LoadingOutlined } from '@ant-design/icons';
import styled from 'styled-components/macro';
import React, { useState, useEffect } from 'react';
import { ANTD_GRAY } from '../../entity/shared/constants';
Expand Down Expand Up @@ -45,6 +45,17 @@ const ChildrenWrapper = styled.div`
padding-left: 12px;
`;

const LoadingWrapper = styled.div`
padding: 8px;
display: flex;
justify-content: center;
svg {
height: 15px;
width: 15px;
}
`;

interface Props {
node: GlossaryNode;
isSelecting?: boolean;
Expand All @@ -63,7 +74,7 @@ function NodeItem(props: Props) {
const [areChildrenVisible, setAreChildrenVisible] = useState(false);
const entityRegistry = useEntityRegistry();
const { entityData } = useEntityData();
const { data } = useGetGlossaryNodeQuery({
const { data, loading } = useGetGlossaryNodeQuery({
variables: { urn: node.urn },
skip: !areChildrenVisible || shouldHideNode,
});
Expand Down Expand Up @@ -126,24 +137,33 @@ function NodeItem(props: Props) {
</NameWrapper>
)}
</NodeWrapper>
{areChildrenVisible && data && data.glossaryNode && (
<ChildrenWrapper>
{(childNodes as GlossaryNode[]).map((child) => (
<NodeItem
node={child}
isSelecting={isSelecting}
hideTerms={hideTerms}
openToEntity={openToEntity}
nodeUrnToHide={nodeUrnToHide}
selectTerm={selectTerm}
selectNode={selectNode}
/>
))}
{!hideTerms &&
(childTerms as GlossaryTerm[]).map((child) => (
<TermItem term={child} isSelecting={isSelecting} selectTerm={selectTerm} />
))}
</ChildrenWrapper>
{areChildrenVisible && (
<>
{!data && loading && (
<LoadingWrapper>
<LoadingOutlined />
</LoadingWrapper>
)}
{data && data.glossaryNode && (
<ChildrenWrapper>
{(childNodes as GlossaryNode[]).map((child) => (
<NodeItem
node={child}
isSelecting={isSelecting}
hideTerms={hideTerms}
openToEntity={openToEntity}
nodeUrnToHide={nodeUrnToHide}
selectTerm={selectTerm}
selectNode={selectNode}
/>
))}
{!hideTerms &&
(childTerms as GlossaryTerm[]).map((child) => (
<TermItem term={child} isSelecting={isSelecting} selectTerm={selectTerm} />
))}
</ChildrenWrapper>
)}
</>
)}
</ItemWrapper>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function GlossaryEntitiesList(props: Props) {
name={node.properties?.name || ''}
urn={node.urn}
type={node.type}
count={(node as GlossaryNodeFragment).children?.count}
count={(node as GlossaryNodeFragment).children?.total}
/>
))}
{terms.map((term) => (
Expand Down
4 changes: 2 additions & 2 deletions datahub-web-react/src/graphql/fragments.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ fragment glossaryNode on GlossaryNode {
properties {
name
}
children: relationships(input: { types: ["IsPartOf"], direction: INCOMING, start: 0, count: 1000 }) {
count
children: relationships(input: { types: ["IsPartOf"], direction: INCOMING, start: 0, count: 10000 }) {
total
}
}

Expand Down
14 changes: 11 additions & 3 deletions datahub-web-react/src/graphql/glossaryNode.graphql
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
fragment childGlossaryTerm on GlossaryTerm {
name
hierarchicalName
properties {
name
}
}

query getGlossaryNode($urn: String!) {
glossaryNode(urn: $urn) {
urn
Expand All @@ -17,19 +25,19 @@ query getGlossaryNode($urn: String!) {
types: ["IsPartOf"]
direction: INCOMING
start: 0
count: 1000
count: 10000
}
) {
count
relationships {
direction
entity {
type
urn
... on GlossaryNode {
...glossaryNode
}
... on GlossaryTerm {
...glossaryTerm
...childGlossaryTerm
}
}
}
Expand Down