-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: expose raw request content under _rawContent #6544
Conversation
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 9bb93f4:
|
looks like it's "lucky" that we only override _state, not recreate a whole results object in places like
Maybe in server side rendering it could not be applied?
instantsearch/packages/instantsearch-core/src/widgets/index-widget.ts Lines 569 to 579 in 0bb5fcb
|
@Haroenv the |
sorry was on the next branch, but this code exists in master too in InstantSearch.js |
I did update my implementation 🙂 |
@Haroenv should I account for instantsearch/packages/instantsearch.js/src/widgets/index/index.ts Lines 693 to 705 in e598230
to do it properly here I'll have to add it to the types, though : derivedHelper.on('result', ({ results, _rawContent }) => {
// The index does not render the results it schedules a new render
// to let all the other indices emit their own results. It allows us to
// run the render process in one pass.
instantSearchInstance.scheduleRender();
// the derived helper is the one which actually searches, but the helper
// which is exposed e.g. via instance.helper, doesn't search, and thus
// does not have access to lastResults, which it used to in pre-federated
// search behavior.
helper!.lastResults = results;
helper!.lastResults._rawContent = _rawContent;
lastValidSearchParameters = results?._state;
}); |
No, that part is just copying the results so already works without changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we know this isn't permeated through the whole life cycle, but because of the limited use case, let's land it like this first. Thanks!
Summary
In order to access some composition-related data (when
getRankingInfo
is requested), we need to access the root content of the API response, not justresults
(cf. last example on this doc).Result
exposing the root content of the API response (excluding
results
that is already exposed) through a_rawContent
non-documented & non-typed property on search results.it can therefor be accessed like this: