search: add validation and alert functions
Created by: rvantonder
Stacked on #8485. Addresses #7293. The more important part of this PR is the changes around the fix. If you are interested in some low level details about search and alerts interaction, read on. Otherwise, just review the diff.
- Currently, we do a lot of potential alert raising after performing search, and also return results. Most alerts happen in
search_results.go
. Some alerts are raised after trying to search, but have no bearing on search results (e.g., checking for quotes in the query). These checks happen far too late in the pipeline. - When we do parsing/checking and return an error earlier in the pipeline (
search.go
), we go through a layer of indirection in thedidYouMeanQuotedResolver
business and wrapper, which is generally hard to reason about. - We need a more direct way to return alerts (not just errors) earlier, before computing results. So I added code where
searchAlert
now implements the GQL type, and a helper functionnewAlert
to make this smoother. - With the helper setup, I can now move alerts to the right places, tidy up some ugly resolver type business, and overall make query validation a separate, smooth process.