feat: rename tenant into workspace (#2553)
* feat: rename tenant into workspace * fix: missing some files and reset not working * fix: wrong import * Use link in company seeds * Use link in company seeds --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
co-authored by
Charles Bochet
parent
bc579d64a6
commit
b86ada6d2b
@@ -0,0 +1,51 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
|
||||
import { GraphQLSchema } from 'graphql';
|
||||
|
||||
import { WorkspaceResolverBuilderMethods } from 'src/workspace/workspace-resolver-builder/interfaces/workspace-resolvers-builder.interface';
|
||||
|
||||
import { TypeDefinitionsGenerator } from './type-definitions.generator';
|
||||
|
||||
import { WorkspaceBuildSchemaOptions } from './interfaces/workspace-build-schema-optionts.interface';
|
||||
import { QueryTypeFactory } from './factories/query-type.factory';
|
||||
import { MutationTypeFactory } from './factories/mutation-type.factory';
|
||||
import { ObjectMetadataInterface } from './interfaces/object-metadata.interface';
|
||||
import { OrphanedTypesFactory } from './factories/orphaned-types.factory';
|
||||
|
||||
@Injectable()
|
||||
export class WorkspaceGraphQLSchemaFactory {
|
||||
private readonly logger = new Logger(WorkspaceGraphQLSchemaFactory.name);
|
||||
|
||||
constructor(
|
||||
private readonly typeDefinitionsGenerator: TypeDefinitionsGenerator,
|
||||
private readonly queryTypeFactory: QueryTypeFactory,
|
||||
private readonly mutationTypeFactory: MutationTypeFactory,
|
||||
private readonly orphanedTypesFactory: OrphanedTypesFactory,
|
||||
) {}
|
||||
|
||||
async create(
|
||||
objectMetadataCollection: ObjectMetadataInterface[],
|
||||
workspaceResolverBuilderMethods: WorkspaceResolverBuilderMethods,
|
||||
options: WorkspaceBuildSchemaOptions = {},
|
||||
): Promise<GraphQLSchema> {
|
||||
// Generate type definitions
|
||||
this.typeDefinitionsGenerator.generate(objectMetadataCollection, options);
|
||||
|
||||
// Generate schema
|
||||
const schema = new GraphQLSchema({
|
||||
query: this.queryTypeFactory.create(
|
||||
objectMetadataCollection,
|
||||
[...workspaceResolverBuilderMethods.queries],
|
||||
options,
|
||||
),
|
||||
mutation: this.mutationTypeFactory.create(
|
||||
objectMetadataCollection,
|
||||
[...workspaceResolverBuilderMethods.mutations],
|
||||
options,
|
||||
),
|
||||
types: this.orphanedTypesFactory.create(),
|
||||
});
|
||||
|
||||
return schema;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user