# Introduction Preparing view-filter and view-group introduction in v2 core engine Moving view from `core-modules` to `metadata-modules` ## What happened ### Created dedicated modules for each view entity: - ViewFieldModule - ViewFilterModule - ViewFilterGroupModule - ViewGroupModule - ViewSortModule ### Each module is now completely independent with its own: - Controller - Resolver - Service - Entity ### Created dedicated abstraction metadata module folder for: - flat-view-field - flat-view ### Dependencies - Eleminated circular dep on ViewModule to all others ones - Granular import not importing the whole viewModule anymore everywhere close https://github.com/twentyhq/core-team-issues/issues/1703
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { type GraphQLResponse } from 'test/integration/graphql/utils/graphql-test-assertions.util';
|
|
import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util';
|
|
|
|
import { type ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
|
|
|
|
import { createViewOperationFactory } from './create-view-operation-factory.util';
|
|
import { createViewData } from './view-data-factory.util';
|
|
|
|
interface CreateViewResponse extends Record<string, unknown> {
|
|
createCoreView: ViewEntity;
|
|
}
|
|
|
|
export const createTestViewWithGraphQL = async (
|
|
overrides: Partial<ViewEntity> = {},
|
|
): Promise<ViewEntity> => {
|
|
const input = createViewData(overrides);
|
|
|
|
const operation = createViewOperationFactory({ data: input });
|
|
const response = (await makeGraphqlAPIRequest(
|
|
operation,
|
|
)) as GraphQLResponse<CreateViewResponse>;
|
|
|
|
if (response.body.errors) {
|
|
throw new Error(
|
|
`Failed to create test view: ${JSON.stringify(response.body.errors)}`,
|
|
);
|
|
}
|
|
|
|
if (!response.body.data) {
|
|
throw new Error('No data returned from createTestViewWithGraphQL');
|
|
}
|
|
|
|
return response.body.data.createCoreView;
|
|
};
|