samedi 25 mai 2019

It can't read cache data by using apollo-client for mobile web(iphone)

I'm setting up a new client, and want to access by mobile web. I can access by web, but it can't access by mobile web. I think it cannot read cache data in mobile web

this is resovler.js

export const defaults = {
  isLoggedIn: Boolean(localStorage.getItem("jwt"))
};

export const resolvers = {
  Mutation: {
    logUserIn: (_, { token }, { cache }) => {
      localStorage.setItem("jwt", token);
      cache.writeData({ data: { isLoggedIn: true } });
    },
    logUserOut: (_, __, { cache }) => {
      localStorage.removeItem("jwt");
      cache.writeData({ data: { isLoggedIn: false } });
    }
  }
};

this is app.js

export default () => {
  const {
    data: { isLoggedIn }
  } = useQuery(QUERY);
  return <AppPresenter isLoggedIn={isLoggedIn} />;
};

if i change the value of isLoggedIn to true from {isLoggedIn} in AppPresenter. I can access in mobile web.




Aucun commentaire:

Enregistrer un commentaire