Skip to content

Commit

Permalink
Add missing variable to refetch query (#23522)
Browse files Browse the repository at this point in the history
https://dagsterlabs.slack.com/archives/C03KE7K92TT/p1723064363721739 for
context.

These refetchQueries are missing variables.
  • Loading branch information
salazarm authored Aug 8, 2024
1 parent 6985c0d commit 5e00ab2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,33 +42,33 @@ export const ScheduleSwitch = (props: Props) => {

const repoAddressSelector = useMemo(() => repoAddressToSelector(repoAddress), [repoAddress]);

const variables = {
id: schedule.id,
selector: {
...repoAddressSelector,
name,
},
};

const {data, loading} = useQuery<ScheduleStateQuery, ScheduleStateQueryVariables>(
SCHEDULE_STATE_QUERY,
{
variables: {
id: schedule.id,
selector: {
...repoAddressSelector,
name,
},
},
},
{variables},
);

const [startSchedule, {loading: toggleOnInFlight}] = useMutation<
StartThisScheduleMutation,
StartThisScheduleMutationVariables
>(START_SCHEDULE_MUTATION, {
onCompleted: displayScheduleMutationErrors,
refetchQueries: [{variables: {id: schedule.id}, query: SCHEDULE_STATE_QUERY}],
refetchQueries: [{variables, query: SCHEDULE_STATE_QUERY}],
awaitRefetchQueries: true,
});
const [stopSchedule, {loading: toggleOffInFlight}] = useMutation<
StopScheduleMutation,
StopScheduleMutationVariables
>(STOP_SCHEDULE_MUTATION, {
onCompleted: displayScheduleMutationErrors,
refetchQueries: [{variables: {id: schedule.id}, query: SCHEDULE_STATE_QUERY}],
refetchQueries: [{variables, query: SCHEDULE_STATE_QUERY}],
awaitRefetchQueries: true,
});

Expand Down
33 changes: 11 additions & 22 deletions js_modules/dagster-ui/packages/ui-core/src/sensors/SensorSwitch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,44 +58,33 @@ export const SensorSwitch = (props: Props) => {

const {id, name} = sensor;

const variables = {
id: sensor.id,
selector: {
...repoAddressSelector,
name,
},
};

const {data, loading} = useQuery<SensorStateQuery, SensorStateQueryVariables>(
SENSOR_STATE_QUERY,
{
variables: {
id: sensor.id,
selector: {
...repoAddressSelector,
name,
},
},
},
{variables},
);

const [startSensor, {loading: toggleOnInFlight}] = useMutation<
StartSensorMutation,
StartSensorMutationVariables
>(START_SENSOR_MUTATION, {
onCompleted: displaySensorMutationErrors,
refetchQueries: [
{
variables: {
id: sensor.id,
selector: {
...repoAddressSelector,
name,
},
},
query: SENSOR_STATE_QUERY,
},
],
refetchQueries: [{variables, query: SENSOR_STATE_QUERY}],
awaitRefetchQueries: true,
});
const [stopSensor, {loading: toggleOffInFlight}] = useMutation<
StopRunningSensorMutation,
StopRunningSensorMutationVariables
>(STOP_SENSOR_MUTATION, {
onCompleted: displaySensorMutationErrors,
refetchQueries: [{variables: {id: sensor.id}, query: SENSOR_STATE_QUERY}],
refetchQueries: [{variables, query: SENSOR_STATE_QUERY}],
awaitRefetchQueries: true,
});
const [setSensorCursor, {loading: cursorMutationInFlight}] = useMutation<
Expand Down

1 comment on commit 5e00ab2

@github-actions
Copy link

Choose a reason for hiding this comment

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

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-bpgt6wowy-elementl.vercel.app

Built with commit 5e00ab2.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.