-
Notifications
You must be signed in to change notification settings - Fork 1
fix(OPENFRAM-002-2): CU-86akhf8u5 3 review findings across 2 files #395
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,12 @@ import { | |
| type AssignmentTargetType, | ||
| } from './types'; | ||
|
|
||
| // TODO(OPENFRAM-002-2): this raw GraphQL POST query predates the react-relay | ||
| // migration mandate for new data-fetching code. It is left in place pending a | ||
| // follow-up migration to useLazyLoadQuery/fragments, since the union-typed | ||
| // response shape (Organization | Machine | KnowledgeBaseItem | Ticket) and the | ||
| // manual field aliasing below need a corresponding Relay fragment per target | ||
| // type to migrate safely. | ||
| const ASSIGNED_ITEMS_QUERY = `#graphql | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ Raw GraphQL POST query used for assigned-items fetch instead of react-relay Did not migrate π€ Prompt for AI agentsfix confidence: π΄ 15 low β review closely β react π/π to teach the reviewer |
||
| query AssignmentsAssignedItems($itemId: ID!, $targetType: AssignmentTargetType!, $first: Int) { | ||
| assignedItems(itemId: $itemId, targetType: $targetType, first: $first) { | ||
|
|
@@ -236,6 +242,18 @@ export interface AssignedItemsResult { | |
| isReady: boolean; | ||
| } | ||
|
|
||
| // Canonical query-key builder for assigned-items queries, kept alongside this | ||
| // hook (no centralized hooks/admin-query-keys.ts module exists in this repo to | ||
| // import from) so any other surface invalidating this cache must reuse this | ||
| // function rather than hand-writing an array literal that can drift. | ||
| export function assignedItemsQueryKey( | ||
| itemType: AssignmentItemType, | ||
| normalizedItemId: string | null, | ||
| targetType: AssignmentTargetType, | ||
| ) { | ||
| return ['assignments', 'assigned-items', itemType, normalizedItemId, targetType] as const; | ||
| } | ||
|
|
||
| function combineAssignedItems(results: UseQueryResult<AssignedItemsPayload, Error>[]): AssignedItemsResult { | ||
| const value: AssignmentsValue = {}; | ||
| const out: AssignedItemsResult = { value, isLoading: false, isReady: true }; | ||
|
|
@@ -277,7 +295,7 @@ export function useAssignedItems({ itemId, itemType, enabled = true }: UseAssign | |
|
|
||
| return useQueries({ | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ Assignment query keys are inline arrays, not imported from a centralized query-keys module Extracted the inline query-key array literal into a new exported π€ Prompt for AI agentsfix confidence: π‘ 75 medium β react π/π to teach the reviewer |
||
| queries: ASSIGNMENT_TARGET_TYPES.map(targetType => ({ | ||
| queryKey: ['assignments', 'assigned-items', itemType, normalizedItemId, targetType], | ||
| queryKey: assignedItemsQueryKey(itemType, normalizedItemId, targetType), | ||
| queryFn: () => fetchAssignedItems(normalizedItemId as string, targetType), | ||
| enabled: isEnabled, | ||
| staleTime: 30_000, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
𦩠π΄ Direct fetch-style GraphQL POST bypasses Relay in device-filters facet fetch
Replaced the raw
apiClient.post('/api/graphql', ...)call inuseCustomersMin(previously usingGET_ORGANIZATIONS_MIN_QUERYfrom../queries/customers-queries) withuseLazyLoadQueryfromreact-relay, matching the pattern used byuse-device-filters.ts. The hook now derivesitemsdirectly from the Relay query response instead of imperative fetch/setState, andfetchis kept as a compatibility shim that updates asearchstate variable to trigger Relay's refetch via variables change. This is UNVERIFIED against the actual Relay environment setup, compiled artifact (useCustomersMinQuerygraphql tag requires relay-compiler to generate__generated__/useCustomersMinQuery.graphql.ts), and callers' expectations thatfetchreturns a Promise resolving with fresh data synchronously β since Relay'suseLazyLoadQuerytriggers a Suspense-based fetch asynchronously, the returneditemsin thefetchcallback's closure may be stale on first call. A complete fix requires: confirming the relay-compiler is run to generate the query artifact, verifying the schema field names (organizations,search,first) match the actual GraphQL schema, wrapping the consuming component in<Suspense>, and reconciling the fetch-callback API contract with actual call sites (likely requiring aRelayEnvironmentProvider-based refetch viauseQueryLoader/usePreloadedQueryinstead ofuseLazyLoadQuery, which is more idiomatic for search-triggered queries but was not shown in the given evidence).π€ Prompt for AI agents
fix confidence: π΄ 40 low β review closely β react π/π to teach the reviewer