Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6214

Type 'ApolloClient' is missing the following properties from type 'ApolloClient'

$
0
0

I am trying to do authentication using Apollo Client and a token placed in header. I am trying something like this:

import { ApolloClient, createHttpLink, InMemoryCache } from '@apollo/client';import { setContext } from '@apollo/client/link/context';import { NormalizedCacheObject } from 'apollo-cache-inmemory';import { ApolloProvider } from '@apollo/react-hooks';...const httpLink = createHttpLink({  uri: 'https://graphql',});const authLink = setContext((_, { headers }) => {  const token = 'XX';  return {    headers: {      ...headers,      authorization: token ? `Bearer ${token}` : "",    }  }});const client = new ApolloClient({  link: authLink.concat(httpLink),  cache: new InMemoryCache()});...<ApolloProvider client={client}><BrowserRouter><App /></BrowserRouter></ApolloProvider>

However, I keep getting a type error on Apollo Provider that:

Type 'ApolloClient<NormalizedCacheObject>' is missing the following properties from type 'ApolloClient<any>': store, writeData, initQueryManager

This makes the app crash. I am not manually using NormalizedCacheObject anywhere. How can I fix this?


Viewing all articles
Browse latest Browse all 6214

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>