Property 'setLink' is missing in type 'ApolloClient<NormalizedCacheObject>' but required in type 'ApolloClient<any>
The @apollo/client package contains the imports from previously decoupled libraries like apollo-client and apollo-cache-inmemory.
If your imports look like this:
import { ApolloClient } from 'apollo-client'import { InMemoryCache, NormalizedCacheObject } from 'apollo-cache-inmemory'
Switch to this:
import { ApolloClient, InMemoryCache, NormalizedCacheObject,} from '@apollo/client'
Solved the same error modifying the interface ApolloProviderProps by adding an union type(|) DefaultClient to the client property in the file ApolloProvider.d.ts
import React from 'react';import { ApolloClient } from '../../core';export interface ApolloProviderProps<TCache> { client: ApolloClient<TCache> | DefaultClient<TCache>; children: React.ReactNode | React.ReactNode[] | null;}export declare const ApolloProvider: React.FC<ApolloProviderProps<any>>;
This solves my issue.
import { ApolloClient, InMemoryCache } from '@apollo/client';const client = new ApolloClient({ uri: 'your_graphql_endpoint', cache: new InMemoryCache(),});