Files
twenty/packages/twenty-server/test/integration/graphql/utils/view-graphql.util.ts
T
Raphaël Bosi 593b064448 Create resolvers and controllers for core views (#13624)
Created:
- Services
- Resolvers
- Controllers
- Tests for services
- Integration tests for GraphQL and Rest

Updated the Rest API playground

Added new feature flag `IS_CORE_VIEW_ENABLED`

Updated `viewFilter` `operand` and `view` `type` to be enums rather than
strings and generated migration file.

Closes https://github.com/twentyhq/core-team-issues/issues/1259

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2025-08-07 18:45:04 +02:00

35 lines
1.1 KiB
TypeScript

import { GraphQLResponse } from 'test/integration/graphql/utils/graphql-test-assertions.util';
import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util';
import { View } from 'src/engine/core-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: View;
}
export const createTestViewWithGraphQL = async (
overrides: Partial<View> = {},
): Promise<View> => {
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;
};