Page MenuHomePhabricator

Use Apollo cache normalization for schedule stop/start

Authored by sashank on Nov 7 2019, 10:01 PM.


Group Reviewers
Restricted Project
R1:b22e0cd23019: Use Apollo cache normalization for schedule stop/start

Previously, the Dagit scheduler page would use optimistic updates to update the state of the schedule state toggle. This diff changes it to properly use Apollo's cache normalization for mutations.

Test Plan

Start and stop schedules from Dagit, verify they are in the correct state

Diff Detail

R1 dagster
Lint OK
No Unit Test Coverage

Event Timeline

sashank created this revision.Nov 7 2019, 10:01 PM
sashank edited the summary of this revision. (Show Details)Nov 7 2019, 10:02 PM
sashank added a reviewer: Restricted Project.
sashank edited the summary of this revision. (Show Details)
sashank edited the test plan for this revision. (Show Details)
sashank updated this revision to Diff 6362.Nov 7 2019, 10:12 PM

Update tests

prha added a subscriber: prha.Nov 7 2019, 10:43 PM

How does this work? Why don't we need the optimisticResponse param described here:

@prha We used to do that manually, but now we let Apollo reconcile the response from the mutation with the store to update the UI.

Since them mutation returns

schedule {

and the root query which the toggle status depends on queries also queries for:

runningSchedules {
    ... other things

Apollo uses the __typename and id to find the record in the store to update with the new status returned from the mutation.

prha added a comment.Nov 7 2019, 11:15 PM

I see... but that means we're no longer "optimistic"... we first have to wait for the server to respond, right?

Yup exactly. But the mutation is fast and it feels instantaneous already

sashank planned changes to this revision.Nov 7 2019, 11:32 PM
sashank updated this revision to Diff 6386.Nov 7 2019, 11:36 PM

Add optimisticResponse to mutations

prha accepted this revision.Nov 8 2019, 12:13 AM

cool, I was just checking that we were doing what we wanted.

But the optimisticResponse change looks good too!


This revision is now accepted and ready to land.Nov 8 2019, 12:13 AM