-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Move settings data model refreshMetadata to sync calls #9046
Conversation
1b6e4cc
to
b1e648a
Compare
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.
LGTM
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.
PR Summary
This PR modifies how metadata refresh operations are handled across the application, moving from Apollo's built-in refetchQueries to explicit synchronous refresh calls.
- Removed Apollo's
refetchQueries
in favor of explicitrefreshObjectMetadataItems()
calls across multiple metadata hooks - Added
network-only
fetch policy touseRefreshObjectMetadataItems
for stronger cache control - Commented out navigation-triggered metadata refresh in
PageChangeEffect.tsx
, potentially affecting state management - Left debugging
console.log
statements inObjectMetadataItemsGater
andObjectMetadataItemsProvider
that should be removed - Modified
useLoadMockedObjectMetadataItems
to handleisAppWaitingForFreshObjectMetadataState
synchronization
13 file(s) reviewed, 11 comment(s)
Edit PR Review Bot Settings | Greptile
@@ -11,6 +11,8 @@ export const ObjectMetadataItemsGater = ({ | |||
isAppWaitingForFreshObjectMetadataState, | |||
); | |||
|
|||
console.log(isAppWaitingForFreshObjectMetadata); |
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.
style: Remove debugging console.log before merging to production
@@ -11,6 +11,7 @@ export const ObjectMetadataItemsProvider = ({ | |||
children, | |||
}: React.PropsWithChildren) => { | |||
const objectMetadataItems = useRecoilValue(objectMetadataItemsState); | |||
console.log('objectMetadataItems', objectMetadataItems); |
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.
style: Remove console.log statement before merging to production
const result = await mutate({ | ||
variables: { input: { relation: formatRelationMetadataInput(input) } }, | ||
awaitRefetchQueries: true, | ||
refetchQueries: [getOperationName(FIND_MANY_OBJECT_METADATA_ITEMS) ?? ''], | ||
}); |
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.
style: No error handling around the mutation. Consider wrapping in try/catch to handle potential network or validation errors.
}); | ||
|
||
await refreshObjectMetadataItems(); |
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.
logic: refreshObjectMetadataItems could fail silently if the network request fails, potentially leaving the UI in an inconsistent state
const result = await mutate({ | ||
variables: { | ||
input: { | ||
field: input, | ||
}, | ||
}, | ||
awaitRefetchQueries: true, | ||
refetchQueries: [getOperationName(FIND_MANY_OBJECT_METADATA_ITEMS) ?? ''], | ||
}); |
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.
style: Consider handling mutation errors before proceeding with refresh
const result = await mutate({ | ||
variables: { | ||
idToDelete, | ||
}, | ||
awaitRefetchQueries: true, | ||
refetchQueries: [getOperationName(FIND_MANY_OBJECT_METADATA_ITEMS) ?? ''], | ||
}); | ||
|
||
await refreshObjectMetadataItems(); | ||
|
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.
logic: No error handling around the mutation or refresh call. If either fails, the error is silently propagated.
const result = await mutate({ | ||
variables: { | ||
idToDelete, | ||
}, | ||
awaitRefetchQueries: true, | ||
refetchQueries: [getOperationName(FIND_MANY_OBJECT_METADATA_ITEMS) ?? ''], | ||
}); | ||
|
||
await refreshObjectMetadataItems(); | ||
|
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.
style: Consider handling mutation errors before calling refreshObjectMetadataItems to avoid unnecessary refreshes on failure
set(objectMetadataItemsState, toSetObjectMetadataItems); | ||
set(isAppWaitingForFreshObjectMetadataState, false); | ||
} |
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.
logic: setting isAppWaitingForFreshObjectMetadataState to false here but never setting it to true anywhere in this flow
}); | ||
|
||
await refreshObjectMetadataItems(); |
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.
style: Consider wrapping refreshObjectMetadataItems in try/catch to handle refresh failures gracefully
}); | ||
|
||
await refreshObjectMetadataItems(); |
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.
style: Consider error handling around refreshObjectMetadataItems call - if it fails, the workspace and views may be out of sync
In this PR, I'm