Sonarly Claude Code 51311288e5 fix(roles): remove duplicate RLS fragment definitions in getRolesQuery
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)
2026-05-07 10:15:31 +00:00
2025-08-07 17:02:12 +02:00

Twenty logo

The #1 Open-Source CRM

Website · Documentation · Roadmap · Discord · Figma

Twenty banner


Why Twenty

Twenty gives technical teams the building blocks for a custom CRM that meets complex business needs and quickly adapts as the business evolves. Twenty is the CRM you build, ship, and version like the rest of your stack.

Learn more about why we built Twenty


Installation

Cloud

The fastest way to get started. Sign up at twenty.com and spin up a workspace in under a minute, with no infrastructure to manage and always up to date.

Build an app

Scaffold a new app with the Twenty CLI:

npx create-twenty-app my-app

Define objects, fields, and views as code:

import { defineObject, FieldType } from 'twenty-sdk/define';

export default defineObject({
  nameSingular: 'deal',
  namePlural: 'deals',
  labelSingular: 'Deal',
  labelPlural: 'Deals',
  fields: [
    { name: 'name', label: 'Name', type: FieldType.TEXT },
    { name: 'amount', label: 'Amount', type: FieldType.CURRENCY },
    { name: 'closeDate', label: 'Close Date', type: FieldType.DATE_TIME },
  ],
});

Then ship it to your workspace:

npx twenty deploy

See the app development guide for objects, views, agents, and logic functions.

Self-hosting

Run Twenty on your own infrastructure with Docker Compose, or contribute locally via the local setup guide.



Everything you need

Twenty gives you the building blocks of a modern CRM (objects, views, workflows, and agents) and lets you extend them as code. Here's a tour of what's in the box.

Want to go deeper? Read the User Guide for product walkthroughs, or the Documentation for developer reference.

Create your apps

Learn more about apps in doc

Stay on top with version control

Learn more about version control in doc

All the tools you need to build anything

Learn more about primitives in doc

Customize your layouts

Learn more about layouts in doc

AI agents and chats

Learn more about AI in doc

Plus all the tools of a good CRM

Learn more about CRM features in doc


Stack

Thanks

Chromatic      Greptile      Sentry      Crowdin

Thanks to these amazing services that we use and recommend for UI testing (Chromatic), code review (Greptile), catching bugs (Sentry) and translating (Crowdin).

Join the Community

Star the repo · Discord · Feature requests · Releases · X · LinkedIn · Crowdin · Contribute

Languages
TypeScript 78%
MDX 18.5%
JavaScript 3.1%
Python 0.2%