@apollo/client exports a type for RequestHandler which is incompatible with the one exported by @openreplay/tracker-graphql, resulting in TS errors when trying to assign the result of tracker.use to a variable of type RequestHandler
Type '(operation: Operation, forward: NextLink) => Observable<unknown>' is not assignable to type 'RequestHandler'.
Types of parameters 'forward' and 'forward' are incompatible.
Types of parameters 'operation' and 'operation' are incompatible.
Type 'Operation' is missing the following properties from type 'Operation': setContext, getContextts(2322)
repro:
import type { RequestHandler } from '@apollo/client/core';
class AnalyticsService {
trackerLink: RequestHandler | undefined = undefined;
init() {
this.trackerLink = tracker.use(createTrackerLink());
}
}
Ref: https://github.com/openreplay/openreplay/blob/5700a16a945797f002f778fa7ebf95a07c79ab98/tracker/tracker-graphql/src/apolloMiddleware.ts#L5-L11
@apollo/client
exports a type forRequestHandler
which is incompatible with the one exported by@openreplay/tracker-graphql
, resulting in TS errors when trying to assign the result oftracker.use
to a variable of typeRequestHandler
repro:
The type from
@apollo/client
should be used instead. Also@apollo/client
should probably be an optional peer dependency in package.json, see: https://yarnpkg.com/configuration/manifest#peerDependenciesMeta.optional