feat: schema version header check (#4563)
closes https://github.com/twentyhq/twenty/issues/4479 tried to catch the error inside various places including https://github.com/twentyhq/twenty/blob/main/packages/twenty-server/src/engine/integrations/exception-handler/exception-handler.service.ts but it seems like the error never reaches the GraphQL module 😮 any idea where we could intercept such an error `Cannot query field`? --------- Co-authored-by: Jérémy Magrin <jeremy.magrin@gmail.com>
This commit is contained in:
@ -6,7 +6,10 @@ import { Request } from 'express';
|
||||
|
||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
||||
|
||||
export type GoogleAPIsRequest = Request & {
|
||||
export type GoogleAPIsRequest = Omit<
|
||||
Request,
|
||||
'user' | 'workspace' | 'cacheVersion'
|
||||
> & {
|
||||
user: {
|
||||
firstName?: string | null;
|
||||
lastName?: string | null;
|
||||
|
||||
@ -6,7 +6,10 @@ import { Request } from 'express';
|
||||
|
||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
||||
|
||||
export type GoogleRequest = Request & {
|
||||
export type GoogleRequest = Omit<
|
||||
Request,
|
||||
'user' | 'workspace' | 'cacheVersion'
|
||||
> & {
|
||||
user: {
|
||||
firstName?: string | null;
|
||||
lastName?: string | null;
|
||||
|
||||
@ -14,6 +14,7 @@ import { FileUploadModule } from 'src/engine/core-modules/file/file-upload/file-
|
||||
import { DataSourceModule } from 'src/engine/metadata-modules/data-source/data-source.module';
|
||||
import { UserModule } from 'src/engine/core-modules/user/user.module';
|
||||
import { WorkspaceWorkspaceMemberListener } from 'src/engine/core-modules/workspace/workspace-workspace-member.listener';
|
||||
import { WorkspaceCacheVersionModule } from 'src/engine/metadata-modules/workspace-cache-version/workspace-cache-version.module';
|
||||
|
||||
import { workspaceAutoResolverOpts } from './workspace.auto-resolver-opts';
|
||||
import { Workspace } from './workspace.entity';
|
||||
@ -27,6 +28,7 @@ import { WorkspaceService } from './services/workspace.service';
|
||||
imports: [
|
||||
BillingModule,
|
||||
FileUploadModule,
|
||||
WorkspaceCacheVersionModule,
|
||||
NestjsQueryTypeOrmModule.forFeature(
|
||||
[Workspace, UserWorkspace, FeatureFlagEntity],
|
||||
'core',
|
||||
|
||||
@ -24,6 +24,7 @@ import { ActivateWorkspaceInput } from 'src/engine/core-modules/workspace/dtos/a
|
||||
import { BillingSubscription } from 'src/engine/core-modules/billing/entities/billing-subscription.entity';
|
||||
import { BillingService } from 'src/engine/core-modules/billing/billing.service';
|
||||
import { DemoEnvGuard } from 'src/engine/guards/demo.env.guard';
|
||||
import { WorkspaceCacheVersionService } from 'src/engine/metadata-modules/workspace-cache-version/workspace-cache-version.service';
|
||||
|
||||
import { Workspace } from './workspace.entity';
|
||||
|
||||
@ -34,6 +35,7 @@ import { WorkspaceService } from './services/workspace.service';
|
||||
export class WorkspaceResolver {
|
||||
constructor(
|
||||
private readonly workspaceService: WorkspaceService,
|
||||
private readonly workspaceCacheVersionService: WorkspaceCacheVersionService,
|
||||
private readonly fileUploadService: FileUploadService,
|
||||
private readonly billingService: BillingService,
|
||||
) {}
|
||||
@ -105,6 +107,13 @@ export class WorkspaceResolver {
|
||||
return 'inactive';
|
||||
}
|
||||
|
||||
@ResolveField(() => String)
|
||||
async currentCacheVersion(
|
||||
@Parent() workspace: Workspace,
|
||||
): Promise<string | null> {
|
||||
return this.workspaceCacheVersionService.getVersion(workspace.id);
|
||||
}
|
||||
|
||||
@ResolveField(() => BillingSubscription)
|
||||
async currentBillingSubscription(
|
||||
@Parent() workspace: Workspace,
|
||||
|
||||
Reference in New Issue
Block a user