Fix search context fetching issue on older version
Created by: abeatrix
Co-authored-by: Giselle Northy [email protected]
This PR is to fix the issue where connecting VSCE to older instances would result in the error below while loading search contexts in search box:
Quoting @northyg from https://github.com/sourcegraph/sourcegraph/issues/31022:
@abeatrix and I did some digging around and found that older versions of Sourcegraph are not compatible with the latest version of VSCE because there is a new field query that was not in the older versions. In other words, when a user has an older Sourcegraph version and is using the latest VSCE, they see Error occurred while loading search contexts In testing, we tried making the query: String! field optional by removing the ! here: Which makes the extension work in both newer and older versions of Sourcegraph, but looked liked we needed to change the backend code as well. Unfortunately that caused this other error when creating a search context:
Due to what Giselle has mentioned above, we have decided not to make direct changes in the shared code base (to remove query
from the search backend file) and created a separate file for the fetchSearchContexts
function for the search box component to use so that it could support displaying search contexts for instances running from version 3.30 to 3.36:
In Version 3.31.2
in Version 3.34.2 (even though it says 3.36.3 in the image)
For reference, query
does not exist in type SearchContext for older instances and hence the Error: Cannot query field "query" on type "SearchContext".
error
I have also set showSearchContextManagement
to false as we currently do not support manage contexts
in app