The project was working just fine until recent got this error out of nowhere. Can't figure out why.
I'm seeing the same error, although I use this:
const link = graphqlHost
? new HttpLink({
uri: graphqlHost,
fetch,
})
: new SchemaLink({ schema, context: createContext(req, apiHost) })
const client = new ApolloClient({ ssrMode: true, link, cache })
In my case I was using yarn and some sub dependency was not using the latest apollo-link version.
Forcing my project to use the latest apollo-link resolved it.
Similar thing here:
lib/initApollo.ts(16,27): error TS2345: Argument of type '{ connectToDevTools: boolean; ssrMode: boolean; link: HttpLink; cache: InMemoryCache; }' is not assignable to parameter of type 'ApolloClientOptions<NormalizedCacheObject>'.
Types of property 'link' are incompatible.
Type 'HttpLink' is not assignable to type 'ApolloLink'.
Types of property 'split' are incompatible.
Type '(test: (op: Operation) => boolean, left: ApolloLink | RequestHandler, right?: ApolloLink | Reques...' is not assignable to type '(test: (op: Operation) => boolean, left: ApolloLink | RequestHandler, right?: ApolloLink | Reques...'. Two different types with this name exist, but they are unrelated.
Types of parameters 'left' and 'left' are incompatible.
Type 'ApolloLink | RequestHandler' is not assignable to type 'ApolloLink | RequestHandler'. Two different types with this name exist, but they are unrelated.
Type 'ApolloLink' is not assignable to type 'ApolloLink | RequestHandler'.
Type 'ApolloLink' is not assignable to type 'RequestHandler'.
Type 'ApolloLink' provides no match for the signature '(operation: Operation, forward?: NextLink): Observable<any>'.
Temp fix:
__UPD:__ got this healed by yarn upgrade
馃
Just wanted say I managed to fix this by installing apollo-link
. Seems the other modules used this new module (perhaps as a peer-dependency).
Sounds like this has been fixed - closing, thanks!
If you are using apollo v3 import onError as
import { onError } from '@apollo/client/link/error';
Most helpful comment
In my case I was using yarn and some sub dependency was not using the latest apollo-link version.
Forcing my project to use the latest apollo-link resolved it.