This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 347
subscribe is not a function #190
Comments
Hi @lifeiscontent
|
@AnujKosambi I actually got it to work. You can see my example here: import { AsyncStorage } from 'react-native';
import {
InMemoryCache,
IntrospectionFragmentMatcher
} from 'apollo-cache-inmemory';
import { ApolloClient } from 'apollo-client';
import { HttpLink } from 'apollo-link-http';
import { onError } from 'apollo-link-error';
import { setContext } from 'apollo-link-context';
import fragmentTypes from './data/fragmentTypes';
const httpLink = new HttpLink({ uri: '/graphql' });
let token;
const withToken = setContext(async request => {
if (!token) {
token = await AsyncStorage.getItem('token');
}
return {
headers: {
authorization: token
}
};
});
const resetToken = onError(({ networkError }) => {
if (networkError && networkError.statusCode === 401) {
// remove cached token on 401 from the server
token = undefined;
}
});
const authFlowLink = withToken.concat(resetToken);
const link = authFlowLink.concat(httpLink);
const cache = new InMemoryCache({
fragmentMatcher: new IntrospectionFragmentMatcher({
introspectionQueryResultData: fragmentTypes
})
});
export default new ApolloClient({
link,
cache
}); |
5 tasks
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
I'm trying to use apollo-link in react native
here's my current client setup code.
and here's the error I'm getting.
The text was updated successfully, but these errors were encountered: