Victor
03/06/2018, 8:42 AMdenish
03/06/2018, 9:22 AMdenish
03/06/2018, 9:22 AMdenish
03/06/2018, 9:23 AMimport { ApolloClient } from 'apollo-client';
import { createHttpLink } from 'apollo-link-http';
import { setContext } from 'apollo-link-context';
import { InMemoryCache } from 'apollo-cache-inmemory';
const httpLink = createHttpLink({
uri: '<http://graphql-api.XXXX.staging.domandtom.com/>'
});
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
return {
headers: {
...headers,
authorization: token ? `Bearer ${token}` : ""
}
}
});
export const apolloClient = new ApolloClient({
link: authLink.concat(httpLink),
cache: new InMemoryCache()
});
Victor
03/06/2018, 9:25 AMdenish
03/06/2018, 9:26 AMmutation ($email: String!, $password: String!) {
signIn(email: $email, password: $password) {
id
access_token
user_id
employee{
first_name
last_name
}
dependent{
first_name
last_name
}
}
}
Victor
03/06/2018, 9:28 AMdenish
03/06/2018, 9:30 AMdenish
03/06/2018, 9:30 AMVictor
03/06/2018, 9:35 AMVictor
03/06/2018, 9:35 AMdenish
03/06/2018, 9:35 AMdenish
03/06/2018, 9:35 AMVictor
03/06/2018, 9:41 AMdenish
03/06/2018, 10:36 AMconst httpLink = createHttpLink({
uri: '<http://graphql-api.flipt.staging.domandtom.com/>',
fetchOptions: {
mode: 'no-cors'
}
});
denish
03/06/2018, 10:37 AM