Closed smeijer closed 5 years ago
IMO, this is vital. Debouncing a query globally is useful in very limited circumstances. It's unlikely that, say, a slider animation and an autocompleted input bar are going to require exactly the same debounce interval.
I'd prefer to pass in an optional debounceTimeout in the context of the query than configure it up front
Like in OP's first example.
// default for when no timeout is specified
const DEBOUNCE_TIMEOUT = 5 * 1000;
export const debounceLink =
new DebounceLink(DEBOUNCE_TIMEOUT);
fetchMore() {
const debounceKey = 'POSTS_KEY';
const debounceTimeout = 1000; // custom, per-query timeout
const context = { debounceKey, debounceTimeout };
const variables = { after, first };
return this.fetchMore({ context, variables, updateQuery });
}
This would let me lazy-load components that handle their own debounce config.
Would be nice if we could set the debounce time on the query level, instead of global scope. Or perhaps bound to a
debounceKey
?My prefered way. Specify the delay in the query, and thereby close to the implementing components:
Alternative option that could be usefull. Supply a
key-delay-map
as second argument to the link constructor: