Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

feat(DerivedHelper): skip request for empty index #938

Merged
merged 3 commits into from
Apr 27, 2023
Merged

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Apr 12, 2023

We currently don't introspect, but if the indexName is empty, the search client will return an error, meaning skipping those queries isn't really a breaking change.

If no queries would be triggered at all, client.search is also not called.

Skipping those queries can be interesting to create patterns like "multiple sibling indices at root of instantsearch" and "orphan indices".

We currently don't introspect, but if the indexName is empty, the search client will return an error, meaning skipping those queries isn't really a breaking change.

Skipping those queries can be interesting to create patterns like "multiple sibling indices at root of instantsearch" and "orphan indices".

(still WIP as I didn't add a test for this yet)
@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 12, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 07e8671:

Sandbox Source
javascript-helper-app Configuration
InstantSearch.js Configuration

Haroenv added a commit to algolia/instantsearch that referenced this pull request Apr 12, 2023
requires algolia/algoliasearch-helper-js#938

Essentially this allows us to create neat non-inheriting indices like this with only three queries sent:

```jsx
const App = (
  <InstantSearch>
    <Index indexName="1" indexId="1a" />
    <Index indexName="1" indexId="1b" />
    <Index indexName="2" />
  </InstantSearch>
);
```

Combined with algolia/react-instantsearch#3690 again, you could also create

```jsx
// 🚨 this isn't possible yet
const App = (
  <InstantSearch>
    <Index indexName="1">
      {/* other widgets, causing no results */}
      <NoResults>
        <Index indexName="1" parentIndexId={null}>
          {/* display stuff from a separate query,
        without interference of inheritance */}
        </Index>
      </NoResults>
    </Index>
  </InstantSearch>
);
```
Haroenv added a commit to algolia/instantsearch that referenced this pull request Apr 26, 2023
requires algolia/algoliasearch-helper-js#938

Essentially this allows us to create neat non-inheriting indices like this with only three queries sent:

```jsx
const App = (
  <InstantSearch>
    <Index indexName="1" indexId="1a" />
    <Index indexName="1" indexId="1b" />
    <Index indexName="2" />
  </InstantSearch>
);
```

Combined with algolia/react-instantsearch#3690 again, you could also create

```jsx
// 🚨 this isn't possible yet
const App = (
  <InstantSearch>
    <Index indexName="1">
      {/* other widgets, causing no results */}
      <NoResults>
        <Index indexName="1" parentIndexId={null}>
          {/* display stuff from a separate query,
        without interference of inheritance */}
        </Index>
      </NoResults>
    </Index>
  </InstantSearch>
);
```
@Haroenv Haroenv marked this pull request as ready for review April 27, 2023 08:36
@Haroenv Haroenv requested review from a team, dhayab and sarahdayan and removed request for a team April 27, 2023 08:36
Copy link
Member

@dhayab dhayab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@Haroenv Haroenv merged commit 79caa4b into develop Apr 27, 2023
@Haroenv Haroenv deleted the feat/empty-index branch April 27, 2023 15:20
Haroenv added a commit that referenced this pull request May 3, 2023
 * chore: delete renovate (#936) 0e3d8cf
 * feat(DerivedHelper): skip request for empty index (#938) 79caa4b
dhayab pushed a commit to algolia/instantsearch that referenced this pull request Jul 10, 2023
dhayab pushed a commit to algolia/instantsearch that referenced this pull request Jul 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants