Skip to content

Conversation

@tresdonicf
Copy link
Contributor

@tresdonicf tresdonicf commented Nov 25, 2025

For DEMOS-1043: this PR removes the debug statements introduced in the previous PR for this effort and reworks the way refetchQueries is used in the <AddDocumentDialog>

The reason the documents aren't updating is because refetchQueries is going to be called as soon as the mutation finishes, but this only puts the document in the document_pending_upload table and thus re-running the query is going to not have any updated document records.

We can useApolloClient to trigger a refetch at an arbitrary time (in this case right after calling the callback onDocumentUploadSucceeded / dismissing the modal) - Another one that's kinda tough to test locally so going to test in dev after it's deployed

@github-actions github-actions bot added the client Relates to the client. label Nov 25, 2025
@demos-git-service-account
Copy link
Contributor

demos-git-service-account commented Nov 25, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.


const VIRUS_SCAN_MAX_ATTEMPTS = 10;
const DOCUMENT_POLL_INTERVAL_MS = 1_000;
const DOCUMENT_POLL_INTERVAL_MS = 2_000;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do half the requests, doesn't seem like this usually finishes within a second but might finish within 2

await clickPromise;
// Advance timer to allow polling to complete
await vi.advanceTimersByTimeAsync(1000);
await vi.advanceTimersByTimeAsync(DOCUMENT_POLL_INTERVAL_MS);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests now reference the real values in case those change the tests will still be accurate

@tresdonicf tresdonicf requested a review from a team November 25, 2025 21:37
Copy link
Contributor

@connor-parke-icf connor-parke-icf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks fine to me! i think there may be a cleaner path to updating the frontend data from polling, but im not familiar enough with how polling plays with how the Apollo client stores its query results to push in any particular direction

Comment on lines +141 to +143
if (refetchQueries) {
await client.refetchQueries({ include: refetchQueries });
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels like there may be a path more intended by apollo for updating frontend data from the result of a polled query, where updates to data arent explicitly caused by mutations. This might be a good example where a direct cache invalidation may be preferred, but its hard to say. I feel like we should avoid direct calls to the apolloclient so far outside the core components, but i cant come up with any concrete reasons why or why not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed to be the most clear route from what I could find but there certainly could be something else out there! I think this pattern is pretty solid for "disjointed" systems where you don't quite know when some sort of data will be available so you just allow the user to call a refresh when they need it 🤷

@tresdonicf tresdonicf added this pull request to the merge queue Nov 26, 2025
Merged via the queue into main with commit 8c5417b Nov 26, 2025
22 checks passed
@tresdonicf tresdonicf deleted the DEMOS-1043-callback branch November 26, 2025 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client Relates to the client.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants