Closes #5069 back-end part And: - do not display schemaPendingUpdates status on remote server lists as this call will become too costly if there are dozens of servers - (refacto) create foreignTableService After this is merged we will be able to delete remoteTable's availableTables column
56 lines
2.0 KiB
TypeScript
56 lines
2.0 KiB
TypeScript
import { UseGuards } from '@nestjs/common';
|
|
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
|
|
|
|
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
|
import { AuthWorkspace } from 'src/engine/decorators/auth/auth-workspace.decorator';
|
|
import { JwtAuthGuard } from 'src/engine/guards/jwt.auth.guard';
|
|
import { FindManyRemoteTablesInput } from 'src/engine/metadata-modules/remote-server/remote-table/dtos/find-many-remote-tables-input';
|
|
import { RemoteTableInput } from 'src/engine/metadata-modules/remote-server/remote-table/dtos/remote-table-input';
|
|
import { RemoteTableDTO } from 'src/engine/metadata-modules/remote-server/remote-table/dtos/remote-table.dto';
|
|
import { RemoteTableService } from 'src/engine/metadata-modules/remote-server/remote-table/remote-table.service';
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Resolver()
|
|
export class RemoteTableResolver {
|
|
constructor(private readonly remoteTableService: RemoteTableService) {}
|
|
|
|
@Query(() => [RemoteTableDTO])
|
|
async findAvailableRemoteTablesByServerId(
|
|
@Args('input') input: FindManyRemoteTablesInput,
|
|
@AuthWorkspace() { id: workspaceId }: Workspace,
|
|
) {
|
|
return this.remoteTableService.findDistantTablesWithStatusByServerId(
|
|
input.id,
|
|
workspaceId,
|
|
input.shouldFetchPendingSchemaUpdates,
|
|
);
|
|
}
|
|
|
|
@Mutation(() => RemoteTableDTO)
|
|
async syncRemoteTable(
|
|
@Args('input') input: RemoteTableInput,
|
|
@AuthWorkspace() { id: workspaceId }: Workspace,
|
|
) {
|
|
return this.remoteTableService.syncRemoteTable(input, workspaceId);
|
|
}
|
|
|
|
@Mutation(() => RemoteTableDTO)
|
|
async unsyncRemoteTable(
|
|
@Args('input') input: RemoteTableInput,
|
|
@AuthWorkspace() { id: workspaceId }: Workspace,
|
|
) {
|
|
return this.remoteTableService.unsyncRemoteTable(input, workspaceId);
|
|
}
|
|
|
|
@Mutation(() => RemoteTableDTO)
|
|
async syncRemoteTableSchemaChanges(
|
|
@Args('input') input: RemoteTableInput,
|
|
@AuthWorkspace() { id: workspaceId }: Workspace,
|
|
) {
|
|
return this.remoteTableService.syncRemoteTableSchemaChanges(
|
|
input,
|
|
workspaceId,
|
|
);
|
|
}
|
|
}
|