fix(front): include isUIEditable/isRemote in CreateOneObjectMetadataItem so new objects aren't read-only until refresh (#21796)

## Problem

After creating a custom object in **Settings → Data Model**, the new
object's **"New Field"** (and **"Add relation"**) buttons are missing.
They only appear after a hard page refresh.

## Root cause

`CreateOneObjectMetadataItem`
(`packages/twenty-front/src/modules/object-metadata/graphql/mutations.ts`)
selected only a subset of object-level fields and omitted
`isUIEditable`, `isRemote`, `isSystem`, `isUICreatable`,
`universalIdentifier`, `shortcut`, and `duplicateCriteria` — all of
which are present in the shared `ObjectMetadataFields` fragment used by
the bootstrap query.

`useCreateOneObjectMetadataItem` writes the mutation response into the
metadata store via `addToDraft`. Because the mutation resolves *after*
the SSE create event and `addToDraft` replaces entries by `id`, the
reduced mutation response overwrites the fuller record that arrived over
SSE. The stored object then has `isUIEditable === undefined`, so
`isObjectMetadataReadOnly` returns `true` (`!undefined`), and
`ObjectFields` hides the action buttons via its `{!readonly && …}`
guard.

A hard refresh "fixes" it only because the bootstrap query repopulates
the store from `ObjectMetadataFields`, which includes the missing
fields.

## Fix

Add the missing object-level fields to the `CreateOneObjectMetadataItem`
selection so a newly created object matches the bootstrap shape, and
regenerate the metadata GraphQL types. No other code changes required.

## How to test

1. Go to **Settings → Data Model** and create a new custom object.
2. Open the new object's **Fields** tab.
3.  The **"New Field"** button is visible immediately — no refresh
needed.

Before this change, the button was hidden until a manual refresh.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/twentyhq/twenty/pull/21796?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
This commit is contained in:
avonian
2026-06-23 10:46:16 +02:00
committed by GitHub
parent 0e6d96bb5e
commit 47b48d83f7
3 changed files with 16 additions and 2 deletions
File diff suppressed because one or more lines are too long
@@ -4,6 +4,7 @@ export const CREATE_ONE_OBJECT_METADATA_ITEM = gql`
mutation CreateOneObjectMetadataItem($input: CreateOneObjectInput!) {
createOneObject(input: $input) {
id
universalIdentifier
nameSingular
namePlural
labelSingular
@@ -11,8 +12,14 @@ export const CREATE_ONE_OBJECT_METADATA_ITEM = gql`
description
icon
color
isRemote
isActive
isSystem
isUIEditable
isUICreatable
isSearchable
shortcut
duplicateCriteria
createdAt
updatedAt
labelIdentifierFieldMetadataId
@@ -28,6 +28,7 @@ export const variables = {
export const responseData = {
id: '',
universalIdentifier: '',
nameSingular: 'viewFilter',
namePlural: 'viewFilters',
labelSingular: 'View Filter',
@@ -35,8 +36,14 @@ export const responseData = {
description: '',
icon: '',
color: null,
isRemote: false,
isActive: true,
isSystem: false,
isUIEditable: true,
isUICreatable: true,
isSearchable: false,
shortcut: null,
duplicateCriteria: null,
createdAt: '',
updatedAt: '',
labelIdentifierFieldMetadataId: '20202020-72ba-4e11-a36d-e17b544541e1',