web: use Apollo Client for `extensions` query
Created by: valerybugakov
Context
Preparation to land https://github.com/sourcegraph/sourcegraph/pull/23351, where Apollo Client persistent cache will be enabled.
Changes
- Updated
browser
platform context GraphQL methods to be more explicit about sending GraphQL requests to the background script.- Added a fallback for Apollo Client
watchQuery
: GraphQL requests initiated via thewatchQuery
method in the main thread of the browser extensions will be sent to the background script to be handled by ourrequestGraphQL
function. - Support for Apollo Client in the background script of the browser extensions can be implemented in a separate PR. Here's an issue about that I plan to discuss with @tjkandala.
- Added a fallback for Apollo Client
- Used Apollo Client to fetch
ExtensionsRegistry
. - Updated
queryConfiguredRegistryExtensions
to use modern generated GraphQL types. - Added general test utility for Apollo Client instance
createGraphQLClientGetter
.
Notes
jest-mock-extended library was added to create createGraphQLClientGetter
helper. It's useful to avoid adding mocks for fields you don't actually need in tests, but Typescript requires them. We get type-safety benefits without a need to add redundant mocks. This library can be useful in a lot of our tests. If there're no concerns about it, I will add a note about it to our testing guidelines in a separate PR.