mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-24 20:42:05 +03:00
Add a dedicated GQL server for metadata available on /meta (#1820)
This commit is contained in:
parent
37475f7c1b
commit
1e91c985df
41
server/patches/@nestjs+graphql+12.0.8.patch
Normal file
41
server/patches/@nestjs+graphql+12.0.8.patch
Normal file
@ -0,0 +1,41 @@
|
||||
diff --git a/node_modules/@nestjs/graphql/dist/schema-builder/graphql-schema.factory.js b/node_modules/@nestjs/graphql/dist/schema-builder/graphql-schema.factory.js
|
||||
index 787bcbc..1c825bd 100644
|
||||
--- a/node_modules/@nestjs/graphql/dist/schema-builder/graphql-schema.factory.js
|
||||
+++ b/node_modules/@nestjs/graphql/dist/schema-builder/graphql-schema.factory.js
|
||||
@@ -32,6 +32,7 @@ let GraphQLSchemaFactory = exports.GraphQLSchemaFactory = GraphQLSchemaFactory_1
|
||||
else {
|
||||
options = scalarsOrOptions;
|
||||
}
|
||||
+ this.typeDefinitionsGenerator.clearTypeDefinitionStorage();
|
||||
lazy_metadata_storage_1.LazyMetadataStorage.load(resolvers);
|
||||
type_metadata_storage_1.TypeMetadataStorage.compile(options.orphanedTypes);
|
||||
this.typeDefinitionsGenerator.generate(options);
|
||||
diff --git a/node_modules/@nestjs/graphql/dist/schema-builder/storages/type-definitions.storage.js b/node_modules/@nestjs/graphql/dist/schema-builder/storages/type-definitions.storage.js
|
||||
index d100444..158c592 100644
|
||||
--- a/node_modules/@nestjs/graphql/dist/schema-builder/storages/type-definitions.storage.js
|
||||
+++ b/node_modules/@nestjs/graphql/dist/schema-builder/storages/type-definitions.storage.js
|
||||
@@ -81,6 +81,10 @@ let TypeDefinitionsStorage = exports.TypeDefinitionsStorage = class TypeDefiniti
|
||||
}
|
||||
return;
|
||||
}
|
||||
+ clear() {
|
||||
+ this.inputTypeDefinitionsLinks = null;
|
||||
+ this.outputTypeDefinitionsLinks = null;
|
||||
+ }
|
||||
};
|
||||
exports.TypeDefinitionsStorage = TypeDefinitionsStorage = tslib_1.__decorate([
|
||||
(0, common_1.Injectable)()
|
||||
diff --git a/node_modules/@nestjs/graphql/dist/schema-builder/type-definitions.generator.js b/node_modules/@nestjs/graphql/dist/schema-builder/type-definitions.generator.js
|
||||
index eb6bcfd..4fbc1ae 100644
|
||||
--- a/node_modules/@nestjs/graphql/dist/schema-builder/type-definitions.generator.js
|
||||
+++ b/node_modules/@nestjs/graphql/dist/schema-builder/type-definitions.generator.js
|
||||
@@ -26,6 +26,9 @@ let TypeDefinitionsGenerator = exports.TypeDefinitionsGenerator = class TypeDefi
|
||||
this.generateObjectTypeDefs(options);
|
||||
this.generateInputTypeDefs(options);
|
||||
}
|
||||
+ clearTypeDefinitionStorage() {
|
||||
+ this.typeDefinitionsStorage.clear();
|
||||
+ }
|
||||
generateInputTypeDefs(options) {
|
||||
const metadata = type_metadata_storage_1.TypeMetadataStorage.getInputTypesMetadata();
|
||||
const inputTypeDefs = metadata.map((metadata) => this.inputTypeDefinitionFactory.create(metadata, options));
|
@ -33,6 +33,7 @@ import {
|
||||
context: ({ req }) => ({ req }),
|
||||
driver: YogaDriver,
|
||||
autoSchemaFile: true,
|
||||
include: [CoreModule],
|
||||
conditionalSchema: async (request) => {
|
||||
try {
|
||||
// Get the SchemaGenerationService from the AppModule
|
||||
|
@ -8,7 +8,7 @@ import { PersonService } from 'src/core/person/person.service';
|
||||
import { CompanyService } from 'src/core/company/company.service';
|
||||
import { PipelineProgressService } from 'src/core/pipeline/services/pipeline-progress.service';
|
||||
import { ViewService } from 'src/core/view/services/view.service';
|
||||
import { DataSourceService } from 'src/tenant/metadata/data-source/data-source.service';
|
||||
import { DataSourceService } from 'src/metadata/data-source/data-source.service';
|
||||
|
||||
import { WorkspaceService } from './workspace.service';
|
||||
|
||||
|
@ -11,7 +11,7 @@ import { PipelineService } from 'src/core/pipeline/services/pipeline.service';
|
||||
import { ViewService } from 'src/core/view/services/view.service';
|
||||
import { PrismaService } from 'src/database/prisma.service';
|
||||
import { assert } from 'src/utils/assert';
|
||||
import { DataSourceService } from 'src/tenant/metadata/data-source/data-source.service';
|
||||
import { DataSourceService } from 'src/metadata/data-source/data-source.service';
|
||||
|
||||
@Injectable()
|
||||
export class WorkspaceService {
|
||||
|
@ -5,7 +5,7 @@ import { PipelineModule } from 'src/core/pipeline/pipeline.module';
|
||||
import { CompanyModule } from 'src/core/company/company.module';
|
||||
import { PersonModule } from 'src/core/person/person.module';
|
||||
import { ViewModule } from 'src/core/view/view.module';
|
||||
import { DataSourceModule } from 'src/tenant/metadata/data-source/data-source.module';
|
||||
import { DataSourceModule } from 'src/metadata/data-source/data-source.module';
|
||||
|
||||
import { WorkspaceService } from './services/workspace.service';
|
||||
import { WorkspaceMemberService } from './services/workspace-member.service';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { DataSourceMetadataModule } from 'src/tenant/metadata/data-source-metadata/data-source-metadata.module';
|
||||
import { EntitySchemaGeneratorModule } from 'src/tenant/metadata/entity-schema-generator/entity-schema-generator.module';
|
||||
import { DataSourceMetadataModule } from 'src/metadata/data-source-metadata/data-source-metadata.module';
|
||||
import { EntitySchemaGeneratorModule } from 'src/metadata/entity-schema-generator/entity-schema-generator.module';
|
||||
|
||||
import { DataSourceService } from './data-source.service';
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
|
||||
import { EnvironmentService } from 'src/integrations/environment/environment.service';
|
||||
import { DataSourceMetadataService } from 'src/tenant/metadata/data-source-metadata/data-source-metadata.service';
|
||||
import { EntitySchemaGeneratorService } from 'src/tenant/metadata/entity-schema-generator/entity-schema-generator.service';
|
||||
import { DataSourceMetadataService } from 'src/metadata/data-source-metadata/data-source-metadata.service';
|
||||
import { EntitySchemaGeneratorService } from 'src/metadata/entity-schema-generator/entity-schema-generator.service';
|
||||
|
||||
import { DataSourceService } from './data-source.service';
|
||||
|
@ -3,9 +3,9 @@ import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
||||
import { DataSource, QueryRunner, Table } from 'typeorm';
|
||||
|
||||
import { EnvironmentService } from 'src/integrations/environment/environment.service';
|
||||
import { DataSourceMetadataService } from 'src/tenant/metadata/data-source-metadata/data-source-metadata.service';
|
||||
import { EntitySchemaGeneratorService } from 'src/tenant/metadata/entity-schema-generator/entity-schema-generator.service';
|
||||
import { TenantMigration } from 'src/tenant/metadata/tenant-migration/tenant-migration.entity';
|
||||
import { DataSourceMetadataService } from 'src/metadata/data-source-metadata/data-source-metadata.service';
|
||||
import { EntitySchemaGeneratorService } from 'src/metadata/entity-schema-generator/entity-schema-generator.service';
|
||||
import { TenantMigration } from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||
|
||||
import { uuidToBase36 } from './data-source.util';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { ObjectMetadataModule } from 'src/tenant/metadata/object-metadata/object-metadata.module';
|
||||
import { ObjectMetadataModule } from 'src/metadata/object-metadata/object-metadata.module';
|
||||
|
||||
import { EntitySchemaGeneratorService } from './entity-schema-generator.service';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
|
||||
import { ObjectMetadataService } from 'src/tenant/metadata/object-metadata/object-metadata.service';
|
||||
import { ObjectMetadataService } from 'src/metadata/object-metadata/object-metadata.service';
|
||||
|
||||
import { EntitySchemaGeneratorService } from './entity-schema-generator.service';
|
||||
|
@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { EntitySchema } from 'typeorm';
|
||||
|
||||
import { ObjectMetadataService } from 'src/tenant/metadata/object-metadata/object-metadata.service';
|
||||
import { ObjectMetadataService } from 'src/metadata/object-metadata/object-metadata.service';
|
||||
|
||||
import { baseColumns } from './base.entity';
|
||||
import {
|
@ -8,7 +8,7 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { ObjectMetadata } from 'src/tenant/metadata/object-metadata/object-metadata.entity';
|
||||
import { ObjectMetadata } from 'src/metadata/object-metadata/object-metadata.entity';
|
||||
|
||||
@Entity('field_metadata')
|
||||
export class FieldMetadata {
|
@ -12,7 +12,7 @@ import { DataSourceService } from './data-source/data-source.service';
|
||||
import { MigrationGeneratorService } from './migration-generator/migration-generator.service';
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Controller('metadata')
|
||||
@Controller('metadata_legacy')
|
||||
export class MetadataController {
|
||||
constructor(
|
||||
private readonly entitySchemaGeneratorService: EntitySchemaGeneratorService,
|
@ -1,5 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm';
|
||||
import { GraphQLModule } from '@nestjs/graphql';
|
||||
|
||||
import { YogaDriverConfig, YogaDriver } from '@graphql-yoga/nestjs';
|
||||
import GraphQLJSON from 'graphql-type-json';
|
||||
|
||||
import { MetadataService } from './metadata.service';
|
||||
import { MetadataController } from './metadata.controller';
|
||||
@ -25,6 +29,15 @@ const typeORMFactory = async (): Promise<TypeOrmModuleOptions> => ({
|
||||
useFactory: typeORMFactory,
|
||||
name: 'metadata',
|
||||
}),
|
||||
GraphQLModule.forRoot<YogaDriverConfig>({
|
||||
context: ({ req }) => ({ req }),
|
||||
driver: YogaDriver,
|
||||
autoSchemaFile: true,
|
||||
include: [MetadataModule],
|
||||
resolvers: { JSON: GraphQLJSON },
|
||||
plugins: [],
|
||||
path: '/metadata',
|
||||
}),
|
||||
DataSourceModule,
|
||||
DataSourceMetadataModule,
|
||||
FieldMetadataModule,
|
@ -1,5 +1,5 @@
|
||||
import { UseGuards } from '@nestjs/common';
|
||||
import { Args, Mutation, Resolver } from '@nestjs/graphql';
|
||||
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
|
||||
|
||||
import { Workspace } from '@prisma/client';
|
||||
|
||||
@ -15,6 +15,11 @@ import { CreateCustomFieldInput } from './args/create-custom-field.input';
|
||||
export class MetadataResolver {
|
||||
constructor(private readonly metadataService: MetadataService) {}
|
||||
|
||||
@Query(() => String)
|
||||
async hello(): Promise<string> {
|
||||
return 'Hello World!';
|
||||
}
|
||||
|
||||
@Mutation(() => String)
|
||||
async createCustomField(
|
||||
@Args() createCustomFieldInput: CreateCustomFieldInput,
|
@ -1,7 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { DataSourceModule } from 'src/tenant/metadata/data-source/data-source.module';
|
||||
import { TenantMigrationModule } from 'src/tenant/metadata/tenant-migration/tenant-migration.module';
|
||||
import { DataSourceModule } from 'src/metadata/data-source/data-source.module';
|
||||
import { TenantMigrationModule } from 'src/metadata/tenant-migration/tenant-migration.module';
|
||||
|
||||
import { MigrationGeneratorService } from './migration-generator.service';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
|
||||
import { DataSourceService } from 'src/tenant/metadata/data-source/data-source.service';
|
||||
import { TenantMigrationService } from 'src/tenant/metadata/tenant-migration/tenant-migration.service';
|
||||
import { DataSourceService } from 'src/metadata/data-source/data-source.service';
|
||||
import { TenantMigrationService } from 'src/metadata/tenant-migration/tenant-migration.service';
|
||||
|
||||
import { MigrationGeneratorService } from './migration-generator.service';
|
||||
|
@ -2,12 +2,12 @@ import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { QueryRunner, Table, TableColumn } from 'typeorm';
|
||||
|
||||
import { DataSourceService } from 'src/tenant/metadata/data-source/data-source.service';
|
||||
import { DataSourceService } from 'src/metadata/data-source/data-source.service';
|
||||
import {
|
||||
TenantMigrationTableChange,
|
||||
TenantMigrationColumnChange,
|
||||
} from 'src/tenant/metadata/tenant-migration/tenant-migration.entity';
|
||||
import { TenantMigrationService } from 'src/tenant/metadata/tenant-migration/tenant-migration.service';
|
||||
} from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||
import { TenantMigrationService } from 'src/metadata/tenant-migration/tenant-migration.service';
|
||||
|
||||
@Injectable()
|
||||
export class MigrationGeneratorService {
|
@ -7,7 +7,7 @@ import {
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { FieldMetadata } from 'src/tenant/metadata/field-metadata/field-metadata.entity';
|
||||
import { FieldMetadata } from 'src/metadata/field-metadata/field-metadata.entity';
|
||||
|
||||
@Entity('object_metadata')
|
||||
export class ObjectMetadata {
|
@ -1,6 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { DataSourceModule } from 'src/tenant/metadata/data-source/data-source.module';
|
||||
import { DataSourceModule } from 'src/metadata/data-source/data-source.module';
|
||||
|
||||
import { TenantMigrationService } from './tenant-migration.service';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
|
||||
import { DataSourceService } from 'src/tenant/metadata/data-source/data-source.service';
|
||||
import { DataSourceService } from 'src/metadata/data-source/data-source.service';
|
||||
|
||||
import { TenantMigrationService } from './tenant-migration.service';
|
||||
|
@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { IsNull } from 'typeorm';
|
||||
|
||||
import { DataSourceService } from 'src/tenant/metadata/data-source/data-source.service';
|
||||
import { DataSourceService } from 'src/metadata/data-source/data-source.service';
|
||||
|
||||
import {
|
||||
TenantMigration,
|
@ -1,6 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { DataSourceModule } from 'src/tenant/metadata/data-source/data-source.module';
|
||||
import { DataSourceModule } from 'src/metadata/data-source/data-source.module';
|
||||
|
||||
import { EntityResolverService } from './entity-resolver.service';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
|
||||
import { DataSourceService } from 'src/tenant/metadata/data-source/data-source.service';
|
||||
import { DataSourceService } from 'src/metadata/data-source/data-source.service';
|
||||
import { EnvironmentService } from 'src/integrations/environment/environment.service';
|
||||
|
||||
import { EntityResolverService } from './entity-resolver.service';
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
import { GraphQLResolveInfo } from 'graphql';
|
||||
import graphqlFields from 'graphql-fields';
|
||||
|
||||
import { DataSourceService } from 'src/tenant/metadata/data-source/data-source.service';
|
||||
import { DataSourceService } from 'src/metadata/data-source/data-source.service';
|
||||
import { EnvironmentService } from 'src/integrations/environment/environment.service';
|
||||
|
||||
import { convertFieldsToGraphQL } from './entity-resolver.util';
|
||||
|
@ -8,8 +8,8 @@ import {
|
||||
GraphQLString,
|
||||
} from 'graphql';
|
||||
|
||||
import { FieldMetadata } from 'src/tenant/metadata/field-metadata/field-metadata.entity';
|
||||
import { ObjectMetadata } from 'src/tenant/metadata/object-metadata/object-metadata.entity';
|
||||
import { FieldMetadata } from 'src/metadata/field-metadata/field-metadata.entity';
|
||||
import { ObjectMetadata } from 'src/metadata/object-metadata/object-metadata.entity';
|
||||
import { pascalCase } from 'src/utils/pascal-case';
|
||||
|
||||
/**
|
||||
|
@ -2,9 +2,9 @@ import { Module } from '@nestjs/common';
|
||||
|
||||
import { EntityResolverModule } from 'src/tenant/entity-resolver/entity-resolver.module';
|
||||
import { JwtAuthGuard } from 'src/guards/jwt.auth.guard';
|
||||
import { DataSourceMetadataModule } from 'src/tenant/metadata/data-source-metadata/data-source-metadata.module';
|
||||
import { EntitySchemaGeneratorModule } from 'src/tenant/metadata/entity-schema-generator/entity-schema-generator.module';
|
||||
import { ObjectMetadataModule } from 'src/tenant/metadata/object-metadata/object-metadata.module';
|
||||
import { DataSourceMetadataModule } from 'src/metadata/data-source-metadata/data-source-metadata.module';
|
||||
import { EntitySchemaGeneratorModule } from 'src/metadata/entity-schema-generator/entity-schema-generator.module';
|
||||
import { ObjectMetadataModule } from 'src/metadata/object-metadata/object-metadata.module';
|
||||
|
||||
import { SchemaGenerationService } from './schema-generation.service';
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
|
||||
import { DataSourceMetadataService } from 'src/tenant/metadata/data-source-metadata/data-source-metadata.service';
|
||||
import { ObjectMetadataService } from 'src/tenant/metadata/object-metadata/object-metadata.service';
|
||||
import { DataSourceMetadataService } from 'src/metadata/data-source-metadata/data-source-metadata.service';
|
||||
import { ObjectMetadataService } from 'src/metadata/object-metadata/object-metadata.service';
|
||||
import { EntityResolverService } from 'src/tenant/entity-resolver/entity-resolver.service';
|
||||
|
||||
import { SchemaGenerationService } from './schema-generation.service';
|
||||
|
@ -9,10 +9,10 @@ import {
|
||||
} from 'graphql';
|
||||
|
||||
import { EntityResolverService } from 'src/tenant/entity-resolver/entity-resolver.service';
|
||||
import { DataSourceMetadataService } from 'src/tenant/metadata/data-source-metadata/data-source-metadata.service';
|
||||
import { DataSourceMetadataService } from 'src/metadata/data-source-metadata/data-source-metadata.service';
|
||||
import { pascalCase } from 'src/utils/pascal-case';
|
||||
import { ObjectMetadataService } from 'src/tenant/metadata/object-metadata/object-metadata.service';
|
||||
import { ObjectMetadata } from 'src/tenant/metadata/object-metadata/object-metadata.entity';
|
||||
import { ObjectMetadataService } from 'src/metadata/object-metadata/object-metadata.service';
|
||||
import { ObjectMetadata } from 'src/metadata/object-metadata/object-metadata.entity';
|
||||
|
||||
import { generateEdgeType } from './graphql-types/edge.graphql-type';
|
||||
import { generateConnectionType } from './graphql-types/connection.graphql-type';
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { MetadataModule } from './metadata/metadata.module';
|
||||
import { MetadataModule } from 'src/metadata/metadata.module';
|
||||
|
||||
import { UniversalModule } from './universal/universal.module';
|
||||
import { SchemaGenerationModule } from './schema-generation/schema-generation.module';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { DataSourceModule } from 'src/tenant/metadata/data-source/data-source.module';
|
||||
import { DataSourceModule } from 'src/metadata/data-source/data-source.module';
|
||||
|
||||
import { UniversalService } from './universal.service';
|
||||
import { UniversalResolver } from './universal.resolver';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
|
||||
import { DataSourceService } from 'src/tenant/metadata/data-source/data-source.service';
|
||||
import { DataSourceService } from 'src/metadata/data-source/data-source.service';
|
||||
import { EnvironmentService } from 'src/integrations/environment/environment.service';
|
||||
|
||||
import { UniversalService } from './universal.service';
|
||||
|
@ -2,7 +2,7 @@ import { Injectable, InternalServerErrorException } from '@nestjs/common';
|
||||
|
||||
import { Workspace } from '@prisma/client';
|
||||
|
||||
import { DataSourceService } from 'src/tenant/metadata/data-source/data-source.service';
|
||||
import { DataSourceService } from 'src/metadata/data-source/data-source.service';
|
||||
import { findManyCursorConnection } from 'src/utils/pagination';
|
||||
|
||||
import { UniversalEntity, PaginatedUniversalEntity } from './universal.entity';
|
||||
|
Loading…
Reference in New Issue
Block a user