- 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.
17 lines
454 B
TypeScript
17 lines
454 B
TypeScript
import { ApolloLink, from, HttpLink } from '@apollo/client/core';
|
|
|
|
type Parameters = { token: null | string | undefined; uri: string };
|
|
|
|
export function createLink({ token, uri }: Parameters) {
|
|
const cacheLink = new ApolloLink((operation, forward) => {
|
|
return forward(operation);
|
|
});
|
|
|
|
const httpLink = new HttpLink({
|
|
headers: token ? { Authorization: `Bearer ${token}` } : undefined,
|
|
uri,
|
|
});
|
|
|
|
return from([cacheLink, httpLink]);
|
|
}
|