BREAKING CHANGES: Converted to use Redux stores. Login now working using Redux.
This commit is contained in:
@@ -1,23 +1,20 @@
|
||||
import React, { Component } from "react";
|
||||
|
||||
import App from "./App";
|
||||
import Spin from "../components/loading-spinner/loading-spinner.component";
|
||||
|
||||
import { ApolloLink } from "apollo-boost";
|
||||
import { InMemoryCache } from "apollo-cache-inmemory";
|
||||
import ApolloClient from "apollo-client";
|
||||
import { split } from "apollo-link";
|
||||
import { setContext } from "apollo-link-context";
|
||||
import { HttpLink } from "apollo-link-http";
|
||||
import apolloLogger from "apollo-link-logger";
|
||||
import { WebSocketLink } from "apollo-link-ws";
|
||||
import { getMainDefinition } from "apollo-utilities";
|
||||
import { InMemoryCache } from "apollo-cache-inmemory";
|
||||
import { setContext } from "apollo-link-context";
|
||||
import { resolvers, typeDefs } from "../graphql/resolvers";
|
||||
import apolloLogger from "apollo-link-logger";
|
||||
import { ApolloLink } from "apollo-boost";
|
||||
import React, { Component } from "react";
|
||||
import { ApolloProvider } from "react-apollo";
|
||||
import { persistCache } from "apollo-cache-persist";
|
||||
import initialState from "../graphql/initial-state";
|
||||
import SpinnerComponent from "../components/loading-spinner/loading-spinner.component";
|
||||
//import { shouldRefreshToken, refreshToken } from "../graphql/middleware";
|
||||
import errorLink from "../graphql/apollo-error-handling";
|
||||
import App from "./App";
|
||||
|
||||
|
||||
|
||||
class AppContainer extends Component {
|
||||
state = {
|
||||
@@ -69,14 +66,8 @@ class AppContainer extends Component {
|
||||
);
|
||||
|
||||
const authLink = setContext((_, { headers }) => {
|
||||
// get the authentication token from local storage if it exists
|
||||
const token = localStorage.getItem("token");
|
||||
// return the headers to the context so httpLink can read them
|
||||
if (token) {
|
||||
// if (shouldRefreshToken) {
|
||||
// refreshToken();
|
||||
// }
|
||||
|
||||
return {
|
||||
headers: {
|
||||
...headers,
|
||||
@@ -99,31 +90,13 @@ class AppContainer extends Component {
|
||||
const client = new ApolloClient({
|
||||
link: ApolloLink.from(middlewares),
|
||||
cache,
|
||||
typeDefs,
|
||||
resolvers,
|
||||
connectToDevTools: true
|
||||
});
|
||||
|
||||
client.writeData({
|
||||
data: initialState
|
||||
});
|
||||
|
||||
try {
|
||||
await persistCache({
|
||||
cache,
|
||||
storage: window.sessionStorage,
|
||||
debug: true
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error restoring Apollo cache", error);
|
||||
}
|
||||
|
||||
this.setState({
|
||||
client,
|
||||
loaded: true
|
||||
});
|
||||
|
||||
//Init local state.
|
||||
}
|
||||
|
||||
componentWillUnmount() {}
|
||||
@@ -132,7 +105,7 @@ class AppContainer extends Component {
|
||||
const { client, loaded } = this.state;
|
||||
|
||||
if (!loaded) {
|
||||
return <Spin />;
|
||||
return <SpinnerComponent />;
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user