-
Notifications
You must be signed in to change notification settings - Fork 11
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
[Package][Genetics] Fix search for Genetics #356
base: main
Are you sure you want to change the base?
Conversation
Thank you @riyavsinha 👍 @chinmehta will be taking a look at the code during the week |
@@ -13,15 +13,19 @@ function useListOption() { | |||
if (newOption.entity === "search") { | |||
history.push(`/search?q=${newOption.name}&page=1`); | |||
} else if (newOption.entity === "study") { | |||
history.push(`/${newOption.entity}/${newOption.studyId}`); | |||
if (newOption.studyId) { |
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.
at this point we should use switch
instead of if conditional statements
if (isArray(value)) { | ||
value.map(i => | ||
typesArray.push({ | ||
type: key === "topHit" ? "topHit" : key, | ||
entity: key, | ||
type: key === "topHit" ? "topHit" : i.__typename.toLowerCase(), |
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.
Apollo primarily provides __typename
for its own functions like caching, we should try to use the response that is present in the schema.
</Box> | ||
); | ||
const SearchSuggestionEl = | ||
searchSuggestions.length > 0 ? ( |
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.
It is good to have a condition, although it is preferred that we modify and pass EXAMPLES
from Genetics > HomePage.tsx
so that we don't see empty search container.
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.
Comments added
Current state of search for genetics:
Description
First issue was that there were no default
searchSuggestions
for the genetics app provided in theSearchContext
, so mapping over the undefined object caused errors. This was fixed by making the defaultsearchSuggestions
an empty array. Also, I only now render the suggestions element + header whensearchSuggestions
is non-empty.The second issue is that it seems the routing logic was only written/updated for the Platform and not Genetics? The
searchUtils
data formatting for Genetics turns the entity types intogenes
,variants
orstudies
, which cause bad urls that do not work. Using__typeName
to lowercase does work for now. This does not affect the Platform because the Platform search results use thevalue.hits
array style. Additionally, theuseListOption
URL construction adds on/associations
for gene and variant type entities, and requires astudyId
for studies which is not present in the Genetics applicationstudy
entities it seems. I have modified that code to account for that for now.However, I believe a better longer term solution would be for each application to pass in an
entityToUrlMapper
function to theuseListOption
hook, since that hook is supposed to be application-agnostic.Issue: # (link)
Deploy preview: (link)
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.
New state for genetics:
Checklist: