vchikalkin b8b8ca6004 Add cache-proxy application with initial setup and configuration
- Created a new cache-proxy application using NestJS, including essential files such as Dockerfile, .gitignore, and .eslintrc.js.
- Implemented core application structure with AppModule, ProxyModule, and ProxyController for handling GraphQL requests.
- Configured caching with Redis and established environment variable management using Zod for validation.
- Added utility functions for query handling and time management, enhancing the application's functionality.
- Included README.md for project documentation and setup instructions.
2025-10-06 20:01:18 +03:00

22 lines
616 B
TypeScript

import { env as environment } from '../config/env';
import { getToken } from '../config/token';
import { createLink } from './link';
import { ApolloClient, InMemoryCache } from '@apollo/client/core';
type Parameters = { token: null | string | undefined };
export function createApolloClient(parameters?: Parameters) {
return new ApolloClient({
cache: new InMemoryCache(),
link: createLink({
token: parameters?.token,
uri: environment.URL_GRAPHQL_CACHED,
}),
});
}
export async function getClientWithToken() {
const token = await getToken();
return createApolloClient({ token });
}