Add redis to useMetadataCache yoga plugin (#5194)

## Context
@lucasbordeau introduced a new Yoga plugin that allows us to cache our
requests (👏), see https://github.com/twentyhq/twenty/pull/5189
I'm simply updating the implementation to allow us to use different
cache storage types such as redis
Also adding a check so it does not use cache for other operations than
ObjectMetadataItems

## Test
locally, first call takes 340ms, 2nd takes 30ms with 'redis' and 13ms
with 'memory'
This commit is contained in:
Weiko
2024-04-26 19:27:09 +02:00
committed by GitHub
parent 5e143f1f49
commit ebc25c8695
3 changed files with 43 additions and 12 deletions

View File

@ -12,6 +12,8 @@ import { EnvironmentService } from 'src/engine/integrations/environment/environm
import { ExceptionHandlerService } from 'src/engine/integrations/exception-handler/exception-handler.service';
import { DataloaderModule } from 'src/engine/dataloaders/dataloader.module';
import { DataloaderService } from 'src/engine/dataloaders/dataloader.service';
import { CacheStorageNamespace } from 'src/engine/integrations/cache-storage/types/cache-storage-namespace.enum';
import { CacheStorageModule } from 'src/engine/integrations/cache-storage/cache-storage.module';
@Module({
imports: [
@ -19,11 +21,17 @@ import { DataloaderService } from 'src/engine/dataloaders/dataloader.service';
driver: YogaDriver,
useFactory: metadataModuleFactory,
imports: [GraphQLConfigModule, DataloaderModule],
inject: [EnvironmentService, ExceptionHandlerService, DataloaderService],
inject: [
EnvironmentService,
ExceptionHandlerService,
DataloaderService,
CacheStorageNamespace.WorkspaceSchema,
],
}),
MetadataEngineModule,
WorkspaceMigrationRunnerModule,
WorkspaceMigrationModule,
CacheStorageModule,
],
})
export class MetadataGraphQLApiModule {}