schon/storefront/src/graphql/apolloClient.ts
Egor fureunoir Gorbunov cc8c2245ee Features: 1) Integrated Apollo Client with caching and query merging; 2) Added GraphQL schema for improved API handling;
Fixes: None;

Extra: Removed unused files including layout, page components, and global styling to align with the new GraphQL integration;
2025-06-30 20:18:42 +03:00

26 lines
825 B
TypeScript

import { ApolloClient, InMemoryCache, HttpLink } from '@apollo/client';
export const apolloClient = new ApolloClient({
ssrMode: typeof window === 'undefined',
link: new HttpLink({
uri: process.env.NEXT_PUBLIC_GRAPHQL_ENDPOINT,
credentials: 'include',
}),
cache: new InMemoryCache({
typePolicies: {
Query: {
fields: {
products: {
keyArgs: false,
merge(existing = { edges: [] }, incoming) {
return {
...incoming,
edges: [...existing.edges, ...incoming.edges],
};
},
},
},
},
},
}),
});