mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-08 15:30:55 +00:00
fix(caching): refetch query on update (#3020)
This commit is contained in:
parent
07bbd50ad2
commit
ea7952ce77
@ -4,7 +4,7 @@ import { Chart, EntityType, GlobalTags } from '../../../../types.generated';
|
|||||||
import { Ownership as OwnershipView } from '../../shared/Ownership';
|
import { Ownership as OwnershipView } from '../../shared/Ownership';
|
||||||
import { EntityProfile } from '../../../shared/EntityProfile';
|
import { EntityProfile } from '../../../shared/EntityProfile';
|
||||||
import ChartHeader from './ChartHeader';
|
import ChartHeader from './ChartHeader';
|
||||||
import { GetChartDocument, useGetChartQuery, useUpdateChartMutation } from '../../../../graphql/chart.generated';
|
import { useGetChartQuery, useUpdateChartMutation } from '../../../../graphql/chart.generated';
|
||||||
import ChartSources from './ChartSources';
|
import ChartSources from './ChartSources';
|
||||||
import ChartDashboards from './ChartDashboards';
|
import ChartDashboards from './ChartDashboards';
|
||||||
import { Message } from '../../../shared/Message';
|
import { Message } from '../../../shared/Message';
|
||||||
@ -24,18 +24,7 @@ const ENABLED_TAB_TYPES = [TabType.Ownership, TabType.Sources, TabType.Propertie
|
|||||||
export default function ChartProfile({ urn }: { urn: string }) {
|
export default function ChartProfile({ urn }: { urn: string }) {
|
||||||
const { loading, error, data } = useGetChartQuery({ variables: { urn } });
|
const { loading, error, data } = useGetChartQuery({ variables: { urn } });
|
||||||
const [updateChart] = useUpdateChartMutation({
|
const [updateChart] = useUpdateChartMutation({
|
||||||
update(cache, { data: newChart }) {
|
refetchQueries: () => ['getChart'],
|
||||||
cache.modify({
|
|
||||||
fields: {
|
|
||||||
chart() {
|
|
||||||
cache.writeQuery({
|
|
||||||
query: GetChartDocument,
|
|
||||||
data: { chart: { ...newChart?.updateChart } },
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error || (!loading && !error && !data)) {
|
if (error || (!loading && !error && !data)) {
|
||||||
|
|||||||
@ -1,10 +1,6 @@
|
|||||||
import { Alert } from 'antd';
|
import { Alert } from 'antd';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {
|
import { useGetDashboardQuery, useUpdateDashboardMutation } from '../../../../graphql/dashboard.generated';
|
||||||
GetDashboardDocument,
|
|
||||||
useGetDashboardQuery,
|
|
||||||
useUpdateDashboardMutation,
|
|
||||||
} from '../../../../graphql/dashboard.generated';
|
|
||||||
import { Dashboard, EntityType, GlobalTags } from '../../../../types.generated';
|
import { Dashboard, EntityType, GlobalTags } from '../../../../types.generated';
|
||||||
import { Ownership as OwnershipView } from '../../shared/Ownership';
|
import { Ownership as OwnershipView } from '../../shared/Ownership';
|
||||||
import { EntityProfile } from '../../../shared/EntityProfile';
|
import { EntityProfile } from '../../../shared/EntityProfile';
|
||||||
@ -28,18 +24,7 @@ const ENABLED_TAB_TYPES = [TabType.Ownership, TabType.Charts, TabType.Properties
|
|||||||
export default function DashboardProfile({ urn }: { urn: string }) {
|
export default function DashboardProfile({ urn }: { urn: string }) {
|
||||||
const { loading, error, data } = useGetDashboardQuery({ variables: { urn } });
|
const { loading, error, data } = useGetDashboardQuery({ variables: { urn } });
|
||||||
const [updateDashboard] = useUpdateDashboardMutation({
|
const [updateDashboard] = useUpdateDashboardMutation({
|
||||||
update(cache, { data: newDashboard }) {
|
refetchQueries: () => ['getDashboard'],
|
||||||
cache.modify({
|
|
||||||
fields: {
|
|
||||||
dashboard() {
|
|
||||||
cache.writeQuery({
|
|
||||||
query: GetDashboardDocument,
|
|
||||||
data: { dashboard: { ...newDashboard?.updateDashboard } },
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error || (!loading && !error && !data)) {
|
if (error || (!loading && !error && !data)) {
|
||||||
|
|||||||
@ -1,10 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Alert } from 'antd';
|
import { Alert } from 'antd';
|
||||||
import {
|
import { useGetDataFlowQuery, useUpdateDataFlowMutation } from '../../../../graphql/dataFlow.generated';
|
||||||
GetDataFlowDocument,
|
|
||||||
useGetDataFlowQuery,
|
|
||||||
useUpdateDataFlowMutation,
|
|
||||||
} from '../../../../graphql/dataFlow.generated';
|
|
||||||
import { EntityProfile } from '../../../shared/EntityProfile';
|
import { EntityProfile } from '../../../shared/EntityProfile';
|
||||||
import { DataFlow, EntityType, GlobalTags } from '../../../../types.generated';
|
import { DataFlow, EntityType, GlobalTags } from '../../../../types.generated';
|
||||||
import DataFlowHeader from './DataFlowHeader';
|
import DataFlowHeader from './DataFlowHeader';
|
||||||
@ -29,18 +25,7 @@ export const DataFlowProfile = ({ urn }: { urn: string }): JSX.Element => {
|
|||||||
};
|
};
|
||||||
const { loading, error, data } = useGetDataFlowQuery({ variables: { urn } });
|
const { loading, error, data } = useGetDataFlowQuery({ variables: { urn } });
|
||||||
const [updateDataFlow] = useUpdateDataFlowMutation({
|
const [updateDataFlow] = useUpdateDataFlowMutation({
|
||||||
update(cache, { data: newDataFlow }) {
|
refetchQueries: () => ['getDataFlow'],
|
||||||
cache.modify({
|
|
||||||
fields: {
|
|
||||||
dataFlow() {
|
|
||||||
cache.writeQuery({
|
|
||||||
query: GetDataFlowDocument,
|
|
||||||
data: { dataFlow: { ...newDataFlow?.updateDataFlow } },
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error || (!loading && !error && !data)) {
|
if (error || (!loading && !error && !data)) {
|
||||||
|
|||||||
@ -1,10 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Alert } from 'antd';
|
import { Alert } from 'antd';
|
||||||
import {
|
import { useGetDataJobQuery, useUpdateDataJobMutation } from '../../../../graphql/dataJob.generated';
|
||||||
useGetDataJobQuery,
|
|
||||||
GetDataJobDocument,
|
|
||||||
useUpdateDataJobMutation,
|
|
||||||
} from '../../../../graphql/dataJob.generated';
|
|
||||||
import { EntityProfile } from '../../../shared/EntityProfile';
|
import { EntityProfile } from '../../../shared/EntityProfile';
|
||||||
import { DataJob, EntityType, GlobalTags } from '../../../../types.generated';
|
import { DataJob, EntityType, GlobalTags } from '../../../../types.generated';
|
||||||
import DataJobHeader from './DataJobHeader';
|
import DataJobHeader from './DataJobHeader';
|
||||||
@ -29,18 +25,7 @@ export const DataJobProfile = ({ urn }: { urn: string }): JSX.Element => {
|
|||||||
const entityRegistry = useEntityRegistry();
|
const entityRegistry = useEntityRegistry();
|
||||||
const { loading, error, data } = useGetDataJobQuery({ variables: { urn } });
|
const { loading, error, data } = useGetDataJobQuery({ variables: { urn } });
|
||||||
const [updateDataJob] = useUpdateDataJobMutation({
|
const [updateDataJob] = useUpdateDataJobMutation({
|
||||||
update(cache, { data: newDataJob }) {
|
refetchQueries: () => ['getDataJob'],
|
||||||
cache.modify({
|
|
||||||
fields: {
|
|
||||||
dataJob() {
|
|
||||||
cache.writeQuery({
|
|
||||||
query: GetDataJobDocument,
|
|
||||||
data: { dataJob: { ...newDataJob?.updateDataJob } },
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error || (!loading && !error && !data)) {
|
if (error || (!loading && !error && !data)) {
|
||||||
|
|||||||
@ -39,7 +39,9 @@ export const DatasetProfile = ({ urn }: { urn: string }): JSX.Element => {
|
|||||||
const { loading, error, data } = useGetDatasetQuery({ variables: { urn } });
|
const { loading, error, data } = useGetDatasetQuery({ variables: { urn } });
|
||||||
|
|
||||||
const user = useGetAuthenticatedUser();
|
const user = useGetAuthenticatedUser();
|
||||||
const [updateDataset] = useUpdateDatasetMutation();
|
const [updateDataset] = useUpdateDatasetMutation({
|
||||||
|
refetchQueries: () => ['getDataset'],
|
||||||
|
});
|
||||||
const isLineageMode = useIsLineageMode();
|
const isLineageMode = useIsLineageMode();
|
||||||
|
|
||||||
if (!loading && error) {
|
if (!loading && error) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user