skip/disable/remove fetch config conditionally
- Dominant language
- JavaScript
- Stars
- 3.4k
- Forks
- 137
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
What I want to do is pretty simple and I thought it would be supported but I can't find such an option so far.
I have an input text on which I'd like to provide autocomplete. But I don't want to trigger requests unless the text size is > 2.
I've tried the following:
```js
const ConnectedCompanyField = connect(({ value }) => {
if (value.length > 2) {
return {
fieldValuesFetch: {
comparison: value,
value: () => searchField(value, ProviderLabel),
},
};
}
})(CompanyField);
```
Even if the `fieldValuesFetch` is not returned when text is small, the former `fieldValuesFetch` remains injected into the component. It looks like a bug to me, but maybe it's intended?
I think it would be easier to provide an ability to "skip" / "ignore" a fetch conditionnally.
Apollo provides an API similar to this:
```js
const ConnectedCompanyField = connect(({ value }) => {
fieldValuesFetch: {
comparison: value,
value: () => searchField(value, ProviderLabel),
skip: value.length <= 2,
},
})(CompanyField);
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.