Using Apollo Client I see how I can skip a query based on props like shown here https://ladwhocodes.com/graphql/skip-a-graphql-query-based-on-conditions/31/
But what if I want to skip calling my query based on a change in state.
I have a query set to poll every 5 seconds but I want to pause this polling while a dialogue is open (to avoid re-rendering the dialogue's parent component, causing the dialogue to re-render and then have to focus the cursor where it was before).
I tried this but it doesn't work. Is my desired behaviour possible?
P.S: Also tried to move dialogue open/close state to the parent component but that doesn't work either.
const [scoreRunDialougeOpen, setScoreRunDialougeOpen] = useState(false)
const { loading, data, error } = useQuery(GET_SELECTED_HEAT, {
variables: {
id: eventId
},
pollInterval: scoreRunDialougeOpen ? undefined : 5000,
skip: scoreRunDialougeOpen,
});