Skip to content

Conversation

prastoin
Copy link
Contributor

@prastoin prastoin commented Oct 13, 2025

Introduction

Adding view-group to core engine v2

close twentyhq/core-team-issues#1665

@prastoin prastoin changed the title [REQUIRES_CACHE_FLUSH] ViewGroup in v2 [WHEN_RELEASED_REQUIRES_CACHE_FLUSH] ViewGroup in v2 Oct 13, 2025
@prastoin prastoin changed the title [WHEN_RELEASED_REQUIRES_CACHE_FLUSH] ViewGroup in v2 [REQUIRES_CACHE_FLUSH][GRAPH_QL_VIEW_GROUP_API_BREAKING_CHANGE] ViewGroup in v2 Oct 13, 2025
@prastoin prastoin changed the title [REQUIRES_CACHE_FLUSH][GRAPH_QL_VIEW_GROUP_API_BREAKING_CHANGE] ViewGroup in v2 [REQUIRES_CACHE_FLUSH][GQL_VIEW_GROUP_API_BREAKING_CHANGE] ViewGroup in v2 Oct 13, 2025
Copy link
Contributor

github-actions bot commented Oct 13, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:64472

This environment will automatically shut down when the PR is closed or after 5 hours.

@prastoin prastoin marked this pull request as ready for review October 13, 2025 12:38
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

This PR implements ViewGroup functionality in the core engine v2, representing a significant architectural migration that introduces view grouping capabilities for organizing records by field values in different views. The implementation spans the entire Twenty stack, from backend services and database entities to frontend hooks and GraphQL operations.

Key changes include:

  • Backend Infrastructure: Complete CRUD implementation for ViewGroup entities with workspace migration support, validation services, flat entity mapping, and caching mechanisms
  • API Breaking Changes: Migration from v1 to v2 GraphQL API patterns where mutations now return full ViewGroup objects instead of booleans and use structured input objects instead of separate parameters
  • Frontend Adaptations: Updated hooks and components to work with the new v2 API structure, maintaining optimistic updates while adapting to the new input/output patterns
  • Database Integration: Enhanced view entities to include viewGroup relationships and updated all related mapping utilities to support the new entity type

The migration follows established v2 patterns with flat entity maps for performance, comprehensive validation, and feature flag support for gradual rollout. This enables users to group records within views by specific field values, enhancing data organization and visualization capabilities.

Important Files Changed

Changed Files
Filename Score Overview
packages/twenty-server/src/engine/metadata-modules/view-group/services/view-group-v2.service.ts 4/5 Major new service implementing complete CRUD operations for ViewGroup entities in v2 engine with flat entity maps and migration integration
packages/twenty-server/src/engine/metadata-modules/view-group/resolvers/view-group.resolver.ts 4/5 Breaking API changes with feature flag routing between v1/v2 services and modified mutation signatures using input DTOs
packages/twenty-front/src/generated/graphql.ts 4/5 Extensive GraphQL schema changes with breaking API modifications for ViewGroup operations and enhanced type definitions
packages/twenty-front/src/modules/views/hooks/internal/usePersistViewGroupRecords.ts 4/5 Refactored to use v2 GraphQL APIs with generated hooks replacing manual Apollo Client mutations
packages/twenty-server/src/engine/workspace-manager/workspace-migration-v2/services/workspace-migration-build-orchestrator.service.ts 5/5 Added ViewGroup support to workspace migration orchestrator following established patterns for other entities
packages/twenty-server/src/engine/metadata-modules/view-group/dtos/inputs/update-view-group.input.ts 5/5 Complete refactor to structured two-class approach with explicit validation and GraphQL schema definitions
packages/twenty-front/src/modules/views/hooks/useSaveCurrentViewGroups.ts 5/5 Updated data structure for view group operations to use input/update pattern for API consistency
packages/twenty-server/src/engine/metadata-modules/flat-view-group/services/workspace-flat-view-group-map-cache.service.ts 5/5 New cache service implementing workspace-scoped caching for view group metadata following established patterns
packages/twenty-server/test/integration/metadata/suites/view-group/utils/create-core-view-group-query-factory.util.ts 5/5 New GraphQL mutation factory for testing ViewGroup creation in v2 architecture
packages/twenty-server/src/engine/metadata-modules/view-group/entities/view-group.entity.ts 5/5 Modified deletedAt field from optional to required property for v2 engine consistency

Confidence score: 4/5

  • This PR introduces complex architectural changes but follows established v2 patterns throughout the codebase
  • Score reflects the comprehensive nature of changes across multiple layers requiring careful coordination during deployment
  • Pay close attention to migration orchestrator service, view group v2 service, and GraphQL schema changes as they form the core of the new functionality

Additional Comments (1)

  1. packages/twenty-front/src/modules/object-record/record-index/hooks/useHandleRecordGroupField.ts, line 150 (link)

    logic: Missing await for async call to getViewFromPrefetchState

75 files reviewed, 11 comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

📊 API Changes Report

GraphQL Schema Changes

GraphQL Schema Changes

[log]
Detected the following changes (18) between schemas:

[log] ✖ Field Mutation.deleteCoreViewGroup changed type from Boolean! to CoreViewGroup!
[log] ✖ Argument id: String! was removed from field Mutation.deleteCoreViewGroup
[log] ✖ Argument input: DeleteViewGroupInput! added to field Mutation.deleteCoreViewGroup
[log] ✖ Field Mutation.destroyCoreViewGroup changed type from Boolean! to CoreViewGroup!
[log] ✖ Argument id: String! was removed from field Mutation.destroyCoreViewGroup
[log] ✖ Argument input: DestroyViewGroupInput! added to field Mutation.destroyCoreViewGroup
[log] ✖ Argument id: String! was removed from field Mutation.updateCoreViewGroup
[log] ✖ Input field fieldMetadataId was removed from input object type UpdateViewGroupInput
[log] ✖ Input field fieldValue was removed from input object type UpdateViewGroupInput
[log] ✖ Input field UpdateViewGroupInput.id changed type from UUID to UUID!
[log] ✖ Input field isVisible was removed from input object type UpdateViewGroupInput
[log] ✖ Input field position was removed from input object type UpdateViewGroupInput
[log] ✖ Input field update of type UpdateViewGroupInputUpdates! was added to input object type UpdateViewGroupInput
[log] ✖ Input field viewId was removed from input object type UpdateViewGroupInput
[log] ✔ Type DeleteViewGroupInput was added
[log] ✔ Type DestroyViewGroupInput was added
[log] ✔ Input field UpdateViewGroupInput.id has description The id of the view group to update
[log] ✔ Type UpdateViewGroupInputUpdates was added
[error] Detected 14 breaking changes
⚠️ Breaking changes or errors detected in GraphQL schema

[log] 
Detected the following changes (18) between schemas:

[log] ✖  Field Mutation.deleteCoreViewGroup changed type from Boolean! to CoreViewGroup!
[log] ✖  Argument id: String! was removed from field Mutation.deleteCoreViewGroup
[log] ✖  Argument input: DeleteViewGroupInput! added to field Mutation.deleteCoreViewGroup
[log] ✖  Field Mutation.destroyCoreViewGroup changed type from Boolean! to CoreViewGroup!
[log] ✖  Argument id: String! was removed from field Mutation.destroyCoreViewGroup
[log] ✖  Argument input: DestroyViewGroupInput! added to field Mutation.destroyCoreViewGroup
[log] ✖  Argument id: String! was removed from field Mutation.updateCoreViewGroup
[log] ✖  Input field fieldMetadataId was removed from input object type UpdateViewGroupInput
[log] ✖  Input field fieldValue was removed from input object type UpdateViewGroupInput
[log] ✖  Input field UpdateViewGroupInput.id changed type from UUID to UUID!
[log] ✖  Input field isVisible was removed from input object type UpdateViewGroupInput
[log] ✖  Input field position was removed from input object type UpdateViewGroupInput
[log] ✖  Input field update of type UpdateViewGroupInputUpdates! was added to input object type UpdateViewGroupInput
[log] ✖  Input field viewId was removed from input object type UpdateViewGroupInput
[log] ✔  Type DeleteViewGroupInput was added
[log] ✔  Type DestroyViewGroupInput was added
[log] ✔  Input field UpdateViewGroupInput.id has description The id of the view group to update
[log] ✔  Type UpdateViewGroupInputUpdates was added
[error] Detected 14 breaking changes
Error generating diff

GraphQL Metadata Schema Changes

GraphQL Metadata Schema Changes

[log]
Detected the following changes (18) between schemas:

[log] ✖ Field Mutation.deleteCoreViewGroup changed type from Boolean! to CoreViewGroup!
[log] ✖ Argument id: String! was removed from field Mutation.deleteCoreViewGroup
[log] ✖ Argument input: DeleteViewGroupInput! added to field Mutation.deleteCoreViewGroup
[log] ✖ Field Mutation.destroyCoreViewGroup changed type from Boolean! to CoreViewGroup!
[log] ✖ Argument id: String! was removed from field Mutation.destroyCoreViewGroup
[log] ✖ Argument input: DestroyViewGroupInput! added to field Mutation.destroyCoreViewGroup
[log] ✖ Argument id: String! was removed from field Mutation.updateCoreViewGroup
[log] ✖ Input field fieldMetadataId was removed from input object type UpdateViewGroupInput
[log] ✖ Input field fieldValue was removed from input object type UpdateViewGroupInput
[log] ✖ Input field UpdateViewGroupInput.id changed type from UUID to UUID!
[log] ✖ Input field isVisible was removed from input object type UpdateViewGroupInput
[log] ✖ Input field position was removed from input object type UpdateViewGroupInput
[log] ✖ Input field update of type UpdateViewGroupInputUpdates! was added to input object type UpdateViewGroupInput
[log] ✖ Input field viewId was removed from input object type UpdateViewGroupInput
[log] ✔ Type DeleteViewGroupInput was added
[log] ✔ Type DestroyViewGroupInput was added
[log] ✔ Input field UpdateViewGroupInput.id has description The id of the view group to update
[log] ✔ Type UpdateViewGroupInputUpdates was added
[error] Detected 14 breaking changes
⚠️ Breaking changes or errors detected in GraphQL metadata schema

[log] 
Detected the following changes (18) between schemas:

[log] ✖  Field Mutation.deleteCoreViewGroup changed type from Boolean! to CoreViewGroup!
[log] ✖  Argument id: String! was removed from field Mutation.deleteCoreViewGroup
[log] ✖  Argument input: DeleteViewGroupInput! added to field Mutation.deleteCoreViewGroup
[log] ✖  Field Mutation.destroyCoreViewGroup changed type from Boolean! to CoreViewGroup!
[log] ✖  Argument id: String! was removed from field Mutation.destroyCoreViewGroup
[log] ✖  Argument input: DestroyViewGroupInput! added to field Mutation.destroyCoreViewGroup
[log] ✖  Argument id: String! was removed from field Mutation.updateCoreViewGroup
[log] ✖  Input field fieldMetadataId was removed from input object type UpdateViewGroupInput
[log] ✖  Input field fieldValue was removed from input object type UpdateViewGroupInput
[log] ✖  Input field UpdateViewGroupInput.id changed type from UUID to UUID!
[log] ✖  Input field isVisible was removed from input object type UpdateViewGroupInput
[log] ✖  Input field position was removed from input object type UpdateViewGroupInput
[log] ✖  Input field update of type UpdateViewGroupInputUpdates! was added to input object type UpdateViewGroupInput
[log] ✖  Input field viewId was removed from input object type UpdateViewGroupInput
[log] ✔  Type DeleteViewGroupInput was added
[log] ✔  Type DestroyViewGroupInput was added
[log] ✔  Input field UpdateViewGroupInput.id has description The id of the view group to update
[log] ✔  Type UpdateViewGroupInputUpdates was added
[error] Detected 14 breaking changes
Error generating diff

⚠️ Please review these API changes carefully before merging.

✅ Breaking Change Protocol

This PR title contains "breaking" and breaking changes were detected - the CI will fail as expected.

📝 Action Required: Please add BREAKING CHANGE: to your commit message to trigger a major version bump.

Example:

feat: add new API endpoint

BREAKING CHANGE: removed deprecated field from User schema

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate ViewGroup in core engine v2

1 participant