[CoreViewField BREAKING_CHANGES] Refactor view field service v2 and resolver (#14396)
## Introduction ### Twenty-sever Standardizing resolver input and transpilation models + return type on destroy and delete ~~Finally~~ Did plug everything under a feature flag and add coverage Next will do same for the view resolver and service v2 ### Twenty-front Refactored view field service in order to use codegenerated strictly typed mutations and adapt to new api contract
This commit is contained in:
@@ -28,7 +28,10 @@ import { mapRecordSortToViewSort } from '@/views/utils/mapRecordSortToViewSort';
|
||||
import { useRecoilCallback } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { v4 } from 'uuid';
|
||||
import { useCreateCoreViewMutation } from '~/generated/graphql';
|
||||
import {
|
||||
type CreateCoreViewFieldMutationVariables,
|
||||
useCreateCoreViewMutation,
|
||||
} from '~/generated/graphql';
|
||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||
|
||||
export const useCreateViewFromCurrentView = (viewBarComponentId?: string) => {
|
||||
@@ -138,7 +141,13 @@ export const useCreateViewFromCurrentView = (viewBarComponentId?: string) => {
|
||||
throw new Error('Failed to create view');
|
||||
}
|
||||
|
||||
await createViewFieldRecords(sourceView.viewFields, { id: newViewId });
|
||||
await createViewFieldRecords(
|
||||
sourceView.viewFields.map<CreateCoreViewFieldMutationVariables>(
|
||||
({ __typename, ...viewField }) => ({
|
||||
input: { ...viewField, viewId: newViewId },
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
if (type === ViewType.Kanban) {
|
||||
if (!isDefined(kanbanFieldMetadataId)) {
|
||||
|
||||
Reference in New Issue
Block a user