diff --git a/src/utils/query-state.ts b/src/utils/query-state.ts index 1858de2..42ad541 100644 --- a/src/utils/query-state.ts +++ b/src/utils/query-state.ts @@ -34,13 +34,7 @@ export function useQueryState( 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); @@ -66,6 +60,18 @@ export function useQueryState( }; } +function useExecuteQueryOnMutation( + query: UseQueryResponse +) { + const store = useStore(); + watch( + () => store.nApolloMutations, + () => { + query.executeQuery({ requestPolicy: "network-only" }); + } + ); +} + function useState( query: UseQueryResponse, devtoolState: Ref,