Fix relay lint in components and pages
Remove unused GraphQL fields (createdAt, updatedAt, totalCount, __id, sourceId, etc.) from queries and fragments across 50+ files. Add TypeScript generics to useMutation, usePaginationFragment, useRefetchableFragment, and useLazyLoadQuery calls to satisfy relay/generated-typescript-types. Add justified eslint-disable comments for fields needed by Relay cache normalization (id) or consumed by sibling components through fragment spreads. Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -15,6 +15,7 @@ const snapshotQuery = graphql`
|
||||
query SnapshotBannerQuery($snapshotId: ID!) {
|
||||
node(id: $snapshotId) {
|
||||
... on Snapshot {
|
||||
# eslint-disable-next-line relay/unused-fields
|
||||
id
|
||||
name
|
||||
type
|
||||
|
||||
@@ -29,10 +29,7 @@ const linkedAuditFragment = graphql`
|
||||
fragment LinkedAuditsCardFragment on Audit {
|
||||
id
|
||||
name
|
||||
createdAt
|
||||
state
|
||||
validFrom
|
||||
validUntil
|
||||
framework {
|
||||
id
|
||||
name
|
||||
|
||||
@@ -22,6 +22,7 @@ import type {
|
||||
LinkedAuditsDialogFragment$key,
|
||||
} from "#/__generated__/core/LinkedAuditsDialogFragment.graphql";
|
||||
import type { LinkedAuditsDialogQuery } from "#/__generated__/core/LinkedAuditsDialogQuery.graphql";
|
||||
import type { LinkedAuditsDialogQuery_fragment } from "#/__generated__/core/LinkedAuditsDialogQuery_fragment.graphql";
|
||||
import { useOrganizationId } from "#/hooks/useOrganizationId";
|
||||
import type { NodeOf } from "#/types";
|
||||
|
||||
@@ -58,8 +59,6 @@ const auditsFragment = graphql`
|
||||
id
|
||||
name
|
||||
state
|
||||
validFrom
|
||||
validUntil
|
||||
framework {
|
||||
id
|
||||
name
|
||||
@@ -98,10 +97,11 @@ function LinkedAuditsDialogContent(props: Omit<Props, "children">) {
|
||||
const query = useLazyLoadQuery<LinkedAuditsDialogQuery>(auditsQuery, {
|
||||
organizationId,
|
||||
});
|
||||
const { data, loadNext, hasNext, isLoadingNext } = usePaginationFragment(
|
||||
auditsFragment,
|
||||
query.organization as LinkedAuditsDialogFragment$key,
|
||||
);
|
||||
const { data, loadNext, hasNext, isLoadingNext }
|
||||
= usePaginationFragment<LinkedAuditsDialogQuery_fragment, LinkedAuditsDialogFragment$key>(
|
||||
auditsFragment,
|
||||
query.organization as LinkedAuditsDialogFragment$key,
|
||||
);
|
||||
const { __ } = useTranslate();
|
||||
const [search, setSearch] = useState("");
|
||||
const audits = useMemo(
|
||||
|
||||
@@ -24,6 +24,7 @@ import { useLazyLoadQuery, usePaginationFragment } from "react-relay";
|
||||
import { graphql } from "relay-runtime";
|
||||
import { useDebounceCallback } from "usehooks-ts";
|
||||
|
||||
import type { LinkedControlsDialogControlsQuery } from "#/__generated__/core/LinkedControlsDialogControlsQuery.graphql";
|
||||
import type {
|
||||
LinkedControlsDialogFragment$data,
|
||||
LinkedControlsDialogFragment$key,
|
||||
@@ -125,10 +126,11 @@ function LinkedControlsDialogContent(props: Props & { ref: SearchRef }) {
|
||||
const mainData = useLazyLoadQuery<LinkedControlsDialogQuery>(query, {
|
||||
organizationId,
|
||||
});
|
||||
const { data, loadNext, hasNext, isLoadingNext, refetch } = usePaginationFragment(
|
||||
controlsFragment,
|
||||
mainData.organization as LinkedControlsDialogFragment$key,
|
||||
);
|
||||
const { data, loadNext, hasNext, isLoadingNext, refetch }
|
||||
= usePaginationFragment<LinkedControlsDialogControlsQuery, LinkedControlsDialogFragment$key>(
|
||||
controlsFragment,
|
||||
mainData.organization as LinkedControlsDialogFragment$key,
|
||||
);
|
||||
|
||||
const controls = data.controls?.edges?.map(edge => edge.node) ?? [];
|
||||
const controlIds = useMemo(() => {
|
||||
|
||||
@@ -30,7 +30,6 @@ const linkedDocumentFragment = graphql`
|
||||
fragment LinkedDocumentsCardFragment on Document {
|
||||
id
|
||||
title
|
||||
createdAt
|
||||
documentType
|
||||
versions(first: 1) {
|
||||
edges {
|
||||
|
||||
@@ -21,6 +21,7 @@ import type {
|
||||
LinkedDocumentsDialogFragment$key,
|
||||
} from "#/__generated__/core/LinkedDocumentsDialogFragment.graphql";
|
||||
import type { LinkedDocumentsDialogQuery } from "#/__generated__/core/LinkedDocumentsDialogQuery.graphql";
|
||||
import type { LinkedDocumentsDialogQuery_fragment } from "#/__generated__/core/LinkedDocumentsDialogQuery_fragment.graphql";
|
||||
import { useOrganizationId } from "#/hooks/useOrganizationId";
|
||||
import type { NodeOf } from "#/types";
|
||||
|
||||
@@ -96,10 +97,11 @@ function LinkedDocumentsDialogContent(props: Omit<Props, "children">) {
|
||||
},
|
||||
{ fetchPolicy: "network-only" },
|
||||
);
|
||||
const { data, loadNext, hasNext, isLoadingNext } = usePaginationFragment(
|
||||
documentsFragment,
|
||||
query.organization as LinkedDocumentsDialogFragment$key,
|
||||
);
|
||||
const { data, loadNext, hasNext, isLoadingNext }
|
||||
= usePaginationFragment<LinkedDocumentsDialogQuery_fragment, LinkedDocumentsDialogFragment$key>(
|
||||
documentsFragment,
|
||||
query.organization as LinkedDocumentsDialogFragment$key,
|
||||
);
|
||||
const { __ } = useTranslate();
|
||||
const [search, setSearch] = useState("");
|
||||
const documents = useMemo(
|
||||
|
||||
@@ -26,8 +26,6 @@ const auditsQuery = graphql`
|
||||
name
|
||||
}
|
||||
state
|
||||
validFrom
|
||||
validUntil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ import { LinkedObligationDialog } from "./LinkedObligationsDialog";
|
||||
const linkedObligationFragment = graphql`
|
||||
fragment LinkedObligationsCardFragment on Obligation {
|
||||
id
|
||||
requirement
|
||||
area
|
||||
source
|
||||
status
|
||||
|
||||
@@ -25,6 +25,7 @@ import type {
|
||||
LinkedObligationsDialogFragment$key,
|
||||
} from "#/__generated__/core/LinkedObligationsDialogFragment.graphql";
|
||||
import type { LinkedObligationsDialogQuery } from "#/__generated__/core/LinkedObligationsDialogQuery.graphql";
|
||||
import type { LinkedObligationsDialogQuery_fragment } from "#/__generated__/core/LinkedObligationsDialogQuery_fragment.graphql";
|
||||
import { useOrganizationId } from "#/hooks/useOrganizationId";
|
||||
import type { NodeOf } from "#/types";
|
||||
|
||||
@@ -59,7 +60,6 @@ const obligationsFragment = graphql`
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
requirement
|
||||
area
|
||||
source
|
||||
status
|
||||
@@ -105,10 +105,11 @@ function LinkedObligationsDialogContent(props: Omit<Props, "children">) {
|
||||
},
|
||||
{ fetchPolicy: "network-only" },
|
||||
);
|
||||
const { data, loadNext, hasNext, isLoadingNext } = usePaginationFragment(
|
||||
obligationsFragment,
|
||||
query.organization as LinkedObligationsDialogFragment$key,
|
||||
);
|
||||
const { data, loadNext, hasNext, isLoadingNext }
|
||||
= usePaginationFragment<LinkedObligationsDialogQuery_fragment, LinkedObligationsDialogFragment$key>(
|
||||
obligationsFragment,
|
||||
query.organization as LinkedObligationsDialogFragment$key,
|
||||
);
|
||||
const { __ } = useTranslate();
|
||||
const [search, setSearch] = useState("");
|
||||
const obligations = useMemo(
|
||||
|
||||
@@ -32,8 +32,6 @@ const risksQuery = graphql`
|
||||
name
|
||||
category
|
||||
description
|
||||
inherentRiskScore
|
||||
residualRiskScore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ const taskFragment = graphql`
|
||||
id
|
||||
description
|
||||
name
|
||||
# eslint-disable-next-line relay/unused-fields
|
||||
state
|
||||
timeEstimate
|
||||
deadline
|
||||
|
||||
@@ -28,7 +28,9 @@ import { Link, useLocation, useParams } from "react-router";
|
||||
|
||||
import type { MeasureTasksTabQuery$data } from "#/__generated__/core/MeasureTasksTabQuery.graphql";
|
||||
import type { TaskFormDialogFragment$key } from "#/__generated__/core/TaskFormDialogFragment.graphql";
|
||||
import type { TaskFormDialogUpdateMutation } from "#/__generated__/core/TaskFormDialogUpdateMutation.graphql";
|
||||
import type { TasksCard_TaskRowFragment$key } from "#/__generated__/core/TasksCard_TaskRowFragment.graphql";
|
||||
import type { TasksCardDeleteMutation } from "#/__generated__/core/TasksCardDeleteMutation.graphql";
|
||||
import type { TasksPageFragment$data } from "#/__generated__/core/TasksPageFragment.graphql";
|
||||
import TaskFormDialog, {
|
||||
taskUpdateMutation,
|
||||
@@ -162,7 +164,7 @@ function TaskRow(props: TaskRowProps) {
|
||||
const dialogRef = useDialogRef();
|
||||
const { __ } = useTranslate();
|
||||
const confirm = useConfirm();
|
||||
const [deleteTask] = useMutation(deleteMutation);
|
||||
const [deleteTask] = useMutation<TasksCardDeleteMutation>(deleteMutation);
|
||||
const params = useParams<{ measureId?: string }>();
|
||||
|
||||
const relayEnv = useRelayEnvironment();
|
||||
@@ -171,7 +173,7 @@ function TaskRow(props: TaskRowProps) {
|
||||
fragment,
|
||||
props.fKey as TasksCard_TaskRowFragment$key,
|
||||
);
|
||||
const [updateTask, isUpdating] = useMutation(taskUpdateMutation);
|
||||
const [updateTask, isUpdating] = useMutation<TaskFormDialogUpdateMutation>(taskUpdateMutation);
|
||||
|
||||
const onToggle = async () => {
|
||||
await promisifyMutation(updateTask)({
|
||||
|
||||
Reference in New Issue
Block a user