Skip to content

Commit

Permalink
feat(react): fix apollo client cache issues in entities' profile pages
Browse files Browse the repository at this point in the history
  • Loading branch information
topwebtek7 committed Jul 7, 2021
1 parent 0cbe5a7 commit e5a8d3d
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ export enum TabType {
const ENABLED_TAB_TYPES = [TabType.Ownership, TabType.Sources, TabType.Properties, TabType.Dashboards];

export default function ChartProfile({ urn }: { urn: string }) {
const { loading, error, data } = useGetChartQuery({ variables: { urn } });
const { loading, error, data } = useGetChartQuery({
variables: { urn },
fetchPolicy: 'cache-and-network',
nextFetchPolicy: 'cache-first',
});
const [updateChart] = useUpdateChartMutation({
update(cache, { data: newChart }) {
cache.modify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ const ENABLED_TAB_TYPES = [TabType.Ownership, TabType.Charts, TabType.Properties
* Responsible for reading & writing users.
*/
export default function DashboardProfile({ urn }: { urn: string }) {
const { loading, error, data } = useGetDashboardQuery({ variables: { urn } });
const { loading, error, data } = useGetDashboardQuery({
variables: { urn },
fetchPolicy: 'cache-and-network',
nextFetchPolicy: 'cache-first',
});
const [updateDashboard] = useUpdateDashboardMutation({
update(cache, { data: newDashboard }) {
cache.modify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ export const DataFlowProfile = ({ urn }: { urn: string }): JSX.Element => {
Ownership: 'Ownership',
Properties: 'Properties',
};
const { loading, error, data } = useGetDataFlowQuery({ variables: { urn } });
const { loading, error, data } = useGetDataFlowQuery({
variables: { urn },
fetchPolicy: 'cache-and-network',
nextFetchPolicy: 'cache-first',
});
const [updateDataFlow] = useUpdateDataFlowMutation({
update(cache, { data: newDataFlow }) {
cache.modify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ const ENABLED_TAB_TYPES = [TabType.Ownership, TabType.Properties];
*/
export const DataJobProfile = ({ urn }: { urn: string }): JSX.Element => {
const entityRegistry = useEntityRegistry();
const { loading, error, data } = useGetDataJobQuery({ variables: { urn } });
const { loading, error, data } = useGetDataJobQuery({
variables: { urn },
fetchPolicy: 'cache-and-network',
nextFetchPolicy: 'cache-first',
});
const [updateDataJob] = useUpdateDataJobMutation({
update(cache, { data: newDataJob }) {
cache.modify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ const ENABLED_TAB_TYPES = [TabType.Properties, TabType.RelatedEntity];

export default function GlossaryTermProfile() {
const { urn } = useUserParams();
const { loading, error, data } = useGetGlossaryTermQuery({ variables: { urn } });
const { loading, error, data } = useGetGlossaryTermQuery({
variables: { urn },
fetchPolicy: 'cache-and-network',
nextFetchPolicy: 'cache-first',
});

const entityRegistry = useEntityRegistry();
const searchTypes = entityRegistry.getSearchEntityTypes();
Expand Down
6 changes: 5 additions & 1 deletion datahub-web-react/src/app/entity/tag/TagProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ type TagPageParams = {
*/
export default function TagProfile() {
const { urn } = useParams<TagPageParams>();
const { loading, error, data } = useGetTagQuery({ variables: { urn } });
const { loading, error, data } = useGetTagQuery({
variables: { urn },
fetchPolicy: 'cache-and-network',
nextFetchPolicy: 'cache-first',
});
const entityRegistry = useEntityRegistry();
const history = useHistory();

Expand Down
6 changes: 5 additions & 1 deletion datahub-web-react/src/app/entity/user/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ const ENABLED_TAB_TYPES = [TabType.Ownership];
*/
export default function UserProfile() {
const { urn } = useUserParams();
const { loading, error, data } = useGetUserQuery({ variables: { urn } });
const { loading, error, data } = useGetUserQuery({
variables: { urn },
fetchPolicy: 'cache-and-network',
nextFetchPolicy: 'cache-first',
});
const username = data?.corpUser?.username;

const ownershipResult = useGetAllEntitySearchResults({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ const messageStyle = { marginTop: '10%' };
*/
export default function UserGroupProfile() {
const { urn } = useUserParams();
const { loading, error, data } = useGetUserGroupQuery({ variables: { urn } });

const { loading, error, data } = useGetUserGroupQuery({
variables: { urn },
fetchPolicy: 'cache-and-network',
nextFetchPolicy: 'cache-first',
});
const name = data?.corpGroup?.name;

const ownershipResult = useGetAllEntitySearchResults({
Expand Down

0 comments on commit e5a8d3d

Please sign in to comment.