Skip to content

skip/disable/remove fetch config conditionally #215

@slorber

Description

@slorber

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:

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:

const ConnectedCompanyField = connect(({ value }) => {
      fieldValuesFetch: {
        comparison: value,
        value: () => searchField(value, ProviderLabel),
       skip: value.length <= 2,
      },
})(CompanyField);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions