Hi Guys. Having a little trouble with react-apollo...
# prisma-whats-new
f
Hi Guys. Having a little trouble with react-apollo. I'm trying to write a query with a variable. The variable is set from localstorage. But it seems that the value from localstorage is not yet available when the query is executed.
Copy code
export default graphql(query, {
  options: {
    variables: {
      id: localStorage.getItem("pm:userId")
    }
  }
})(SelectOrganization);
Copy code
import gql from "graphql-tag";

export default gql`
  query User($id: ID!){
    user(id: $id) {
      memberships {
        organization {
          name,
          id
        }
        role
      }
    }
  }
`;
In my login component I set the localstorage item. and after that i push to the route
Copy code
window.localStorage.setItem("pm:token", token);
        window.localStorage.setItem("pm:userId", userId);
        debugger;
        this.props.history.push("/organization/select");
in the debugger the localstorage items are set