Additional fixes for firebase login. Capture basic local state.
This commit is contained in:
@@ -9,7 +9,7 @@ import { HttpLink } from "apollo-link-http";
|
||||
import ApolloClient from "apollo-client";
|
||||
import { InMemoryCache } from "apollo-cache-inmemory";
|
||||
|
||||
import Spin from '../components/loading-spinner/loading-spinner.component'
|
||||
import Spin from "../components/loading-spinner/loading-spinner.component";
|
||||
|
||||
const UPSERT_USER = gql`
|
||||
mutation upsert_user($authEmail: String!, $authToken: String!) {
|
||||
@@ -24,6 +24,12 @@ const UPSERT_USER = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
const SET_CURRENT_USER = gql`
|
||||
mutation SetCurrentUser($user: User!) {
|
||||
setCurrentUser(user: $user) @client
|
||||
}
|
||||
`;
|
||||
|
||||
const client = new ApolloClient({
|
||||
link: new HttpLink({
|
||||
uri: process.env.REACT_APP_GRAPHQL_ENDPOINT
|
||||
@@ -44,8 +50,8 @@ export default function Auth() {
|
||||
mutation: UPSERT_USER,
|
||||
variables: { authEmail: user.email, authToken: user.uid }
|
||||
})
|
||||
.then(r => console.log(r))
|
||||
.catch(error => console.log("ERROR!!!!", error));
|
||||
.then(r => console.log("Successful Upsert", r))
|
||||
.catch(error => console.log("Upsert error!!!!", error));
|
||||
|
||||
const token = await user.getIdToken();
|
||||
const idTokenResult = await user.getIdTokenResult();
|
||||
|
||||
@@ -6,13 +6,14 @@ import ApolloClient from "apollo-client";
|
||||
import { InMemoryCache } from "apollo-cache-inmemory";
|
||||
import { resolvers, typeDefs } from "../graphql/resolvers";
|
||||
import initialState from "../graphql/initial-state";
|
||||
import { gql } from "apollo-boost";
|
||||
//Styling imports
|
||||
import "./App.css";
|
||||
|
||||
//Component Imports
|
||||
import SignIn from "../components/landing-components/sign-in/sign-in.component";
|
||||
import LandingPage from "../pages/landing/landing.component";
|
||||
import Manage from "../pages/manage/manage.component";
|
||||
import SignIn from "../components/sign-in-form/sign-in-form.component";
|
||||
import LandingPage from "../pages/landing/landing.page";
|
||||
import Manage from "../pages/manage/manage.page";
|
||||
|
||||
import PrivateRoute from "../utils/private-route";
|
||||
|
||||
@@ -31,8 +32,17 @@ export default function App({ authState }) {
|
||||
resolvers,
|
||||
typeDefs
|
||||
});
|
||||
|
||||
//Init local state.
|
||||
client.writeData({
|
||||
data: { ...initialState, authState }
|
||||
data: {
|
||||
...initialState,
|
||||
currentUser: {
|
||||
__typename: null,
|
||||
email: authState.user.email,
|
||||
displayName: authState.user.displayName
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user