From 51311288e527cbfd42e26c44cd0bd3094bcc670f Mon Sep 17 00:00:00 2001 From: Sonarly Claude Code Date: Thu, 7 May 2026 10:15:31 +0000 Subject: [PATCH] fix(roles): remove duplicate RLS fragment definitions in getRolesQuery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://sonarly.com/issue/35597?type=bug The settings roles page fails with a GraphQL validation error due to duplicate fragment definitions in the GetRoles query, preventing users from viewing or managing roles. Fix: ## What Changed Removed duplicate GraphQL fragment definitions from `getRolesQuery.ts`: 1. **Removed imports** (lines 7-8): - `ROW_LEVEL_PERMISSION_PREDICATE_FRAGMENT` - `ROW_LEVEL_PERMISSION_PREDICATE_GROUP_FRAGMENT` 2. **Removed fragment inclusions** from the gql template (lines 20-21): - `${ROW_LEVEL_PERMISSION_PREDICATE_FRAGMENT}` - `${ROW_LEVEL_PERMISSION_PREDICATE_GROUP_FRAGMENT}` ## Why This Fixes the Bug The query was including the RLS fragment definitions twice: - Once directly in `getRolesQuery.ts` (lines 20-21) - Once inside `OBJECT_PERMISSION_FRAGMENT` (which is included on line 16) When Apollo Client compiled the query, it encountered duplicate definitions of `RowLevelPermissionPredicateFragment` and `RowLevelPermissionPredicateGroupFragment`, causing the GraphQL validation error: "Fields '__type' conflict because they have differing arguments." The fix removes the direct inclusion while keeping the fragments available through `OBJECT_PERMISSION_FRAGMENT`, which correctly defines them for its nested fields. ## Query Structure After Fix The query still fetches all the same data: - `getRoles.objectPermissions.rowLevelPermissionPredicates` uses the fragment from `OBJECT_PERMISSION_FRAGMENT` - `getRoles.rowLevelPermissionPredicates` uses the same fragment definition (available in the query scope via `OBJECT_PERMISSION_FRAGMENT`) - No duplicate definitions, no validation error ## Pattern Consistency This fix aligns with the team's established pattern. Other queries using `OBJECT_PERMISSION_FRAGMENT` correctly omit direct RLS fragment imports: - `upsertObjectPermissionsMutation.ts` ✓ - `userQueryFragment.ts` ✓ - `getRolesQuery.ts` ✓ (after this fix) --- .../modules/settings/roles/graphql/queries/getRolesQuery.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/twenty-front/src/modules/settings/roles/graphql/queries/getRolesQuery.ts b/packages/twenty-front/src/modules/settings/roles/graphql/queries/getRolesQuery.ts index 4fe85d8604c..fd5bbcc57a9 100644 --- a/packages/twenty-front/src/modules/settings/roles/graphql/queries/getRolesQuery.ts +++ b/packages/twenty-front/src/modules/settings/roles/graphql/queries/getRolesQuery.ts @@ -4,8 +4,6 @@ import { FIELD_PERMISSION_FRAGMENT } from '@/settings/roles/graphql/fragments/fi import { OBJECT_PERMISSION_FRAGMENT } from '@/settings/roles/graphql/fragments/objectPermissionFragment'; import { PERMISSION_FLAG_FRAGMENT } from '@/settings/roles/graphql/fragments/permissionFlagFragment'; import { ROLE_FRAGMENT } from '@/settings/roles/graphql/fragments/roleFragment'; -import { ROW_LEVEL_PERMISSION_PREDICATE_FRAGMENT } from '@/settings/roles/graphql/fragments/rowLevelPermissionPredicateFragment'; -import { ROW_LEVEL_PERMISSION_PREDICATE_GROUP_FRAGMENT } from '@/settings/roles/graphql/fragments/rowLevelPermissionPredicateGroupFragment'; import { PARTIAL_WORKSPACE_MEMBER_QUERY_FRAGMENT } from '@/workspace-member/graphql/fragments/partialWorkspaceMemberQueryFragment'; import { gql } from '@apollo/client'; @@ -17,8 +15,6 @@ export const GET_ROLES = gql` ${PERMISSION_FLAG_FRAGMENT} ${OBJECT_PERMISSION_FRAGMENT} ${FIELD_PERMISSION_FRAGMENT} - ${ROW_LEVEL_PERMISSION_PREDICATE_FRAGMENT} - ${ROW_LEVEL_PERMISSION_PREDICATE_GROUP_FRAGMENT} query GetRoles { getRoles { ...RoleFragment