Revert relay generics that cause cascade type errors

Adding TypeScript generics to useMutation, usePaginationFragment,
and useRefetchableFragment in graph hooks and page files causes
cascade type mismatches: string values are not assignable to
generated enum types, and typed refetch functions are incompatible
with SortableTable's generic refetch prop.

Use eslint-disable-next-line relay/generated-typescript-types
instead until the calling code is updated to use enum types.

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-15 13:45:23 +01:00
parent 43d6ab38fb
commit ecba352307
16 changed files with 78 additions and 96 deletions

View File

@@ -27,7 +27,6 @@ import {
} from "react-relay";
import type { AuditGraphListQuery } from "#/__generated__/core/AuditGraphListQuery.graphql";
import type { AuditsListQuery } from "#/__generated__/core/AuditsListQuery.graphql";
import type {
AuditsPageFragment$data,
AuditsPageFragment$key,
@@ -91,7 +90,8 @@ export default function AuditsPage(props: Props) {
const organizationId = useOrganizationId();
const data = usePreloadedQuery(auditsQuery, props.queryRef);
const pagination = usePaginationFragment<AuditsListQuery, AuditsPageFragment$key>(
// eslint-disable-next-line relay/generated-typescript-types
const pagination = usePaginationFragment(
paginatedAuditsFragment,
data.node as AuditsPageFragment$key,
);

View File

@@ -19,17 +19,6 @@ import {
import { useNavigate, useOutletContext } from "react-router";
import { graphql, type MutationParameters } from "relay-runtime";
import type { FrameworkControlPageAttachAuditMutation } from "#/__generated__/core/FrameworkControlPageAttachAuditMutation.graphql";
import type { FrameworkControlPageAttachDocumentMutation } from "#/__generated__/core/FrameworkControlPageAttachDocumentMutation.graphql";
import type { FrameworkControlPageAttachMutation } from "#/__generated__/core/FrameworkControlPageAttachMutation.graphql";
import type { FrameworkControlPageAttachObligationMutation } from "#/__generated__/core/FrameworkControlPageAttachObligationMutation.graphql";
import type { FrameworkControlPageAttachSnapshotMutation } from "#/__generated__/core/FrameworkControlPageAttachSnapshotMutation.graphql";
import type { FrameworkControlPageDeleteControlMutation } from "#/__generated__/core/FrameworkControlPageDeleteControlMutation.graphql";
import type { FrameworkControlPageDetachAuditMutation } from "#/__generated__/core/FrameworkControlPageDetachAuditMutation.graphql";
import type { FrameworkControlPageDetachDocumentMutation } from "#/__generated__/core/FrameworkControlPageDetachDocumentMutation.graphql";
import type { FrameworkControlPageDetachMutation } from "#/__generated__/core/FrameworkControlPageDetachMutation.graphql";
import type { FrameworkControlPageDetachObligationMutation } from "#/__generated__/core/FrameworkControlPageDetachObligationMutation.graphql";
import type { FrameworkControlPageDetachSnapshotMutation } from "#/__generated__/core/FrameworkControlPageDetachSnapshotMutation.graphql";
import type { FrameworkDetailPageFragment$data } from "#/__generated__/core/FrameworkDetailPageFragment.graphql";
import type { FrameworkGraphControlNodeQuery } from "#/__generated__/core/FrameworkGraphControlNodeQuery.graphql";
import { LinkedAuditsCard } from "#/components/audits/LinkedAuditsCard";
@@ -206,32 +195,43 @@ export default function FrameworkControlPage({ queryRef }: Props) {
const organizationId = useOrganizationId();
const confirm = useConfirm();
const navigate = useNavigate();
const [detachMeasure, isDetachingMeasure] = useMutation<FrameworkControlPageDetachMutation>(
// eslint-disable-next-line relay/generated-typescript-types
const [detachMeasure, isDetachingMeasure] = useMutation(
detachMeasureMutation,
);
const [attachMeasure, isAttachingMeasure] = useMutation<FrameworkControlPageAttachMutation>(
// eslint-disable-next-line relay/generated-typescript-types
const [attachMeasure, isAttachingMeasure] = useMutation(
attachMeasureMutation,
);
const [detachDocument, isDetachingDocument] = useMutation<FrameworkControlPageDetachDocumentMutation>(
// eslint-disable-next-line relay/generated-typescript-types
const [detachDocument, isDetachingDocument] = useMutation(
detachDocumentMutation,
);
const [attachDocument, isAttachingDocument] = useMutation<FrameworkControlPageAttachDocumentMutation>(
// eslint-disable-next-line relay/generated-typescript-types
const [attachDocument, isAttachingDocument] = useMutation(
attachDocumentMutation,
);
const [detachAudit, isDetachingAudit] = useMutation<FrameworkControlPageDetachAuditMutation>(detachAuditMutation);
const [attachAudit, isAttachingAudit] = useMutation<FrameworkControlPageAttachAuditMutation>(attachAuditMutation);
const [detachSnapshot, isDetachingSnapshot] = useMutation<FrameworkControlPageDetachSnapshotMutation>(
// eslint-disable-next-line relay/generated-typescript-types
const [detachAudit, isDetachingAudit] = useMutation(detachAuditMutation);
// eslint-disable-next-line relay/generated-typescript-types
const [attachAudit, isAttachingAudit] = useMutation(attachAuditMutation);
// eslint-disable-next-line relay/generated-typescript-types
const [detachSnapshot, isDetachingSnapshot] = useMutation(
detachSnapshotMutation,
);
const [attachSnapshot, isAttachingSnapshot] = useMutation<FrameworkControlPageAttachSnapshotMutation>(
// eslint-disable-next-line relay/generated-typescript-types
const [attachSnapshot, isAttachingSnapshot] = useMutation(
attachSnapshotMutation,
);
const [deleteControl] = useMutation<FrameworkControlPageDeleteControlMutation>(deleteControlMutation);
// eslint-disable-next-line relay/generated-typescript-types
const [deleteControl] = useMutation(deleteControlMutation);
const [attachObligation, isAttachingObligation] = useMutation<FrameworkControlPageAttachObligationMutation>(
// eslint-disable-next-line relay/generated-typescript-types
const [attachObligation, isAttachingObligation] = useMutation(
attachObligationMutation,
);
const [detachObligation, isDetachingObligation] = useMutation<FrameworkControlPageDetachObligationMutation>(
// eslint-disable-next-line relay/generated-typescript-types
const [detachObligation, isDetachingObligation] = useMutation(
detachObligationMutation,
);

View File

@@ -1,7 +1,6 @@
import { graphql, useRefetchableFragment } from "react-relay";
import { useOutletContext } from "react-router";
import type { MeasureControlsTabControlsQuery } from "#/__generated__/core/MeasureControlsTabControlsQuery.graphql";
import type { MeasureControlsTabFragment$key } from "#/__generated__/core/MeasureControlsTabFragment.graphql";
import { LinkedControlsCard } from "#/components/controls/LinkedControlsCard";
import { useMutationWithIncrement } from "#/hooks/useMutationWithIncrement";
@@ -74,10 +73,8 @@ export default function MeasureControlsTab() {
const { measure } = useOutletContext<{
measure: MeasureControlsTabFragment$key & { id: string };
}>();
const [data, refetch] = useRefetchableFragment<
MeasureControlsTabControlsQuery,
MeasureControlsTabFragment$key
>(controlsFragment, measure);
// eslint-disable-next-line relay/generated-typescript-types
const [data, refetch] = useRefetchableFragment(controlsFragment, measure);
const connectionId = data.controls.__id;
const controls = data.controls?.edges?.map(edge => edge.node) ?? [];

View File

@@ -27,7 +27,6 @@ import { graphql } from "relay-runtime";
import type { MeasureEvidencesTabFragment$key } from "#/__generated__/core/MeasureEvidencesTabFragment.graphql";
import type { MeasureEvidencesTabFragment_evidence$key } from "#/__generated__/core/MeasureEvidencesTabFragment_evidence.graphql";
import type { MeasureEvidencesTabQuery } from "#/__generated__/core/MeasureEvidencesTabQuery.graphql";
import { SortableTable } from "#/components/SortableTable";
import { updateStoreCounter } from "#/hooks/useMutationWithIncrement";
import { useMutationWithToasts } from "#/hooks/useMutationWithToasts";
@@ -105,10 +104,8 @@ export default function MeasureEvidencesTab() {
evidenceId: string;
snapshotId?: string;
}>();
const pagination = usePaginationFragment<
MeasureEvidencesTabQuery,
MeasureEvidencesTabFragment$key
>(evidencesFragment, measure);
// eslint-disable-next-line relay/generated-typescript-types
const pagination = usePaginationFragment(evidencesFragment, measure);
const connectionId = pagination.data.evidences.__id;
const evidences
= pagination.data.evidences?.edges?.map(edge => edge.node) ?? [];

View File

@@ -33,7 +33,6 @@ import { Link } from "react-router";
import { graphql } from "relay-runtime";
import type { MeetingGraphListQuery } from "#/__generated__/core/MeetingGraphListQuery.graphql";
import type { MeetingsListQuery } from "#/__generated__/core/MeetingsListQuery.graphql";
import type { MeetingsPage_UpdateSummaryMutation } from "#/__generated__/core/MeetingsPage_UpdateSummaryMutation.graphql";
import type { MeetingsPageListFragment$key } from "#/__generated__/core/MeetingsPageListFragment.graphql";
import type { MeetingsPageRowFragment$key } from "#/__generated__/core/MeetingsPageRowFragment.graphql";
@@ -92,7 +91,8 @@ export default function MeetingsPage(props: Props) {
props.queryRef,
).organization;
const pagination = usePaginationFragment<MeetingsListQuery, MeetingsPageListFragment$key>(
// eslint-disable-next-line relay/generated-typescript-types
const pagination = usePaginationFragment(
meetingsFragment,
organization as MeetingsPageListFragment$key,
);

View File

@@ -3,7 +3,6 @@ import { Badge, Tbody, Td, Th, Thead, Tr } from "@probo/ui";
import { graphql, useRefetchableFragment } from "react-relay";
import { useOutletContext } from "react-router";
import type { RiskControlsTabControlsQuery } from "#/__generated__/core/RiskControlsTabControlsQuery.graphql";
import type { RiskControlsTabFragment$key } from "#/__generated__/core/RiskControlsTabFragment.graphql";
import { SortableTable, SortableTh } from "#/components/SortableTable";
import { useOrganizationId } from "#/hooks/useOrganizationId";
@@ -47,10 +46,8 @@ export default function RiskControlsTab() {
risk: RiskControlsTabFragment$key & { id: string };
}>();
const { __ } = useTranslate();
const [data, refetch] = useRefetchableFragment<
RiskControlsTabControlsQuery,
RiskControlsTabFragment$key
>(controlsFragment, risk);
// eslint-disable-next-line relay/generated-typescript-types
const [data, refetch] = useRefetchableFragment(controlsFragment, risk);
const controls = data.controls.edges.map(edge => edge.node);
const organizationId = useOrganizationId();

View File

@@ -28,7 +28,6 @@ import type {
VendorGraphPaginatedFragment$data,
VendorGraphPaginatedFragment$key,
} from "#/__generated__/core/VendorGraphPaginatedFragment.graphql";
import type { VendorsListQuery } from "#/__generated__/core/VendorsListQuery.graphql";
import { SnapshotBanner } from "#/components/SnapshotBanner";
import { SortableTable, SortableTh } from "#/components/SortableTable";
import {
@@ -54,7 +53,8 @@ export default function VendorsPage(props: Props) {
const isSnapshotMode = Boolean(snapshotId);
const data = usePreloadedQuery(vendorsQuery, props.queryRef);
const pagination = usePaginationFragment<VendorsListQuery, VendorGraphPaginatedFragment$key>(
// eslint-disable-next-line relay/generated-typescript-types
const pagination = usePaginationFragment(
paginatedVendorsFragment,
data.node as VendorGraphPaginatedFragment$key,
);