Skip to content
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

fix(recommend): update TrendingFacetHit facetValue type to string #1498

Merged
merged 1 commit into from Dec 14, 2023

Conversation

raed667
Copy link
Contributor

@raed667 raed667 commented Dec 14, 2023

Why

The trending-facets API only returns type string for facetValue.

A follow-up on #1494 as other models return items/hits which are of type RecordWithObjectID

However, trending-facets model returns a list of TrendingFacetHit which (by definition) don't have an objectID property.

How

To simplify the code, we can remove the type argument TObject for trending-facets

Impact

If you're not using TypeScript or the trending-facets model, there is nothing to change. You can ignore the following.

Otherwise, you will need to remove the type argument passed to getTrendingFacets and the code goes from this:

type FacetType = {
  facetName: string;
  facetValue: string;
}
const { results } = await client.getTrendingFacets<FacetType>(/**/)

To this:

const { results } = await client.getTrendingFacets(/**/)

@@ -1,5 +1,5 @@
export type TrendingFacetHit<TObject> = {
export type TrendingFacetHit = {
Copy link
Contributor

Choose a reason for hiding this comment

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

if this type is exported, it's a breaking change, someone who would be using TrendingFacetHit<string> will get a typescript error. Instead all generics should stay, defaulted to string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO it is fine to have a build step breaking change in this case as it is a bug fix in typings.

Plus the usage for this model is very small and the update will be a one liner documented in the release notes.

@raed667 raed667 requested a review from Haroenv December 14, 2023 13:47
Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

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

BC ok because of low impact

@shortcuts
Copy link
Member

BC ok because of low impact

might still worth a minor right?

@shortcuts shortcuts merged commit ac9d6e2 into master Dec 14, 2023
7 of 8 checks passed
@shortcuts shortcuts deleted the fix-recommend-trending-facet-string branch December 14, 2023 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants