I have a query that takes input params, say date
const { loading, data, error } = useQuery(GET_LIST, {
variables: {
input: {
date: date,
},
},
});
export const GET_LIST = gql`
query list($input: ListParams) {
list(input: $input) {
totalCount
recordCount
list {
listId
date
qty
amount
currency
}
}
}
`;
input ListParams {
date: String
}
I need to fetch the list, where the user can filter based on date. Now on initial load, date is not set, query is called. The user sets a date, no issues, the query is called again with the the date value, now when the user removes the date filter, the date value becomes undefined, and I would expect useQuery to be called again with no variables this time, but it is never called.
I have tried setting empty string as well, even then useQuery does not get called which is not the intended behaviour
input: {
date: date||'',
},