Untitled
plain_text
2 months ago
618 B
1
Indexable
Never
// 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(), });