27 likes
·
1.1K reads
2 comments
·Jul 20, 2022
Jul 20, 2022
Thanks for sharing Dhaiwat Pandya
·
·Sep 25, 2022
Sep 25, 2022
The apollo client configuration seems to be changed a bit now.
import {
ApolloClient,
createHttpLink,
gql,
InMemoryCache,
} from "@apollo/client";
import { setContext } from "@apollo/client/link/context";
const API_URL = "YOUR_URL";
const httpLink = createHttpLink({ uri: API_URL });
const authLink = setContext((_, { headers }) => {
const token = localStorage.getItem("access_token");
return {
headers: {
...headers,
"x-access-token": token ? `Bearer ${token}` : "",
},
};
});
export const apolloClient = new ApolloClient({
link: authLink.concat(httpLink),
cache: new InMemoryCache(),
});
·