Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
extract useExecuteQueryOnMutation()
Browse files Browse the repository at this point in the history
  • Loading branch information
TaiSakuma committed Sep 18, 2023
1 parent c0724b9 commit ec5ba7e
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/utils/query-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@ export function useQueryState<T, V extends AnyVariables>(
error.value = val === State.Error ? "Error from Dev Tools" : null;
});

const store = useStore();
watch(
() => store.nApolloMutations,
() => {
query.executeQuery({ requestPolicy: "network-only" });
}
);
useExecuteQueryOnMutation(query);

const { refreshing, refreshError, refresh } = useRefresh(query);

Expand All @@ -66,6 +60,18 @@ export function useQueryState<T, V extends AnyVariables>(
};
}

function useExecuteQueryOnMutation<T, V extends AnyVariables>(
query: UseQueryResponse<T, V>
) {
const store = useStore();
watch(
() => store.nApolloMutations,
() => {
query.executeQuery({ requestPolicy: "network-only" });
}
);
}

function useState<T, V extends AnyVariables>(
query: UseQueryResponse<T, V>,
devtoolState: Ref<State>,
Expand Down

0 comments on commit ec5ba7e

Please sign in to comment.