Untitled
unknown
plain_text
2 years ago
618 B
7
Indexable
// src/apollo.js
import { ApolloClient, InMemoryCache, createHttpLink } from '@apollo/client/core';
import { setContext } from '@apollo/client/link/context';
const httpLink = createHttpLink({
uri: 'YOUR_GRAPHQL_API_ENDPOINT',
});
const authLink = setContext((_, { headers }) => {
// You can add any authentication logic here, like adding an authorization token to headers
return {
headers: {
...headers,
// Add your headers here if needed
},
};
});
export const apolloClient = new ApolloClient({
link: authLink.concat(httpLink),
cache: new InMemoryCache(),
});
Editor is loading...