In this PR: - removing ugprade-0.24 commands as we are releasing 0.30 - introducing cache:flush command - refactoring upgrade command and sync-metadata command to use the ActiveWorkspacesCommand so they consistently run on all workspaces or selected workspaces Fixes: - clear localStorage on sign out - fix missing workspaceMember in verify resolver - do not throw on datasource already destroyed exception which can happen with race condition when several resolvers are resolving in parallel
58 lines
2.3 KiB
TypeScript
58 lines
2.3 KiB
TypeScript
import { YogaDriverConfig } from '@graphql-yoga/nestjs';
|
|
import GraphQLJSON from 'graphql-type-json';
|
|
|
|
import { useCachedMetadata } from 'src/engine/api/graphql/graphql-config/hooks/use-cached-metadata';
|
|
import { useThrottler } from 'src/engine/api/graphql/graphql-config/hooks/use-throttler';
|
|
import { MetadataGraphQLApiModule } from 'src/engine/api/graphql/metadata-graphql-api.module';
|
|
import { CacheStorageService } from 'src/engine/core-modules/cache-storage/services/cache-storage.service';
|
|
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
|
|
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
|
|
import { useGraphQLErrorHandlerHook } from 'src/engine/core-modules/graphql/hooks/use-graphql-error-handler.hook';
|
|
import { DataloaderService } from 'src/engine/dataloaders/dataloader.service';
|
|
import { renderApolloPlayground } from 'src/engine/utils/render-apollo-playground.util';
|
|
|
|
export const metadataModuleFactory = async (
|
|
environmentService: EnvironmentService,
|
|
exceptionHandlerService: ExceptionHandlerService,
|
|
dataloaderService: DataloaderService,
|
|
cacheStorageService: CacheStorageService,
|
|
): Promise<YogaDriverConfig> => {
|
|
const config: YogaDriverConfig = {
|
|
autoSchemaFile: true,
|
|
include: [MetadataGraphQLApiModule],
|
|
renderGraphiQL() {
|
|
return renderApolloPlayground({ path: 'metadata' });
|
|
},
|
|
resolvers: { JSON: GraphQLJSON },
|
|
plugins: [
|
|
useThrottler({
|
|
ttl: environmentService.get('API_RATE_LIMITING_TTL'),
|
|
limit: environmentService.get('API_RATE_LIMITING_LIMIT'),
|
|
identifyFn: (context) => {
|
|
return context.req.user?.id ?? context.req.ip ?? 'anonymous';
|
|
},
|
|
}),
|
|
useGraphQLErrorHandlerHook({
|
|
exceptionHandlerService,
|
|
}),
|
|
useCachedMetadata({
|
|
cacheGetter: cacheStorageService.get.bind(cacheStorageService),
|
|
cacheSetter: cacheStorageService.set.bind(cacheStorageService),
|
|
operationsToCache: ['ObjectMetadataItems'],
|
|
}),
|
|
],
|
|
path: '/metadata',
|
|
context: () => ({
|
|
loaders: dataloaderService.createLoaders(),
|
|
}),
|
|
};
|
|
|
|
if (environmentService.get('DEBUG_MODE')) {
|
|
config.renderGraphiQL = () => {
|
|
return renderApolloPlayground({ path: 'metadata' });
|
|
};
|
|
}
|
|
|
|
return config;
|
|
};
|