From 0bfcd9a70196274d1d2c91f195bfd4950054c250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Malfait?= Date: Thu, 21 May 2026 18:40:48 +0200 Subject: [PATCH] fix(api-keys): refresh API keys list after key creation (#20806) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New API keys are created successfully but the API keys table can keep showing a stale pre-create result, so users think the key vanished. This blocks key management from the expected UI flow. Fix: Updated the API key creation mutation to explicitly synchronize Apollo cache for the API keys list: - In `SettingsDevelopersApiKeysNew.tsx`, imported `GetApiKeysDocument`. - Changed `useMutation(CreateApiKeyDocument)` to: - `refetchQueries: [GetApiKeysDocument]` - `awaitRefetchQueries: true` Why: the list page (`SettingsApiKeysTable`) reads from `GetApiKeysDocument`, and creation previously did not invalidate/refetch that query. With this change, successful creation refreshes the list query so the new key appears when the user returns to APIs & Webhooks. Validation attempted: - `npx nx lint:diff-with-main twenty-front` → failed due missing Nx modules in this environment. - `npx nx typecheck twenty-front` → failed due missing Nx modules in this environment. Authored by Sonarly by autonomous analysis (run 44851). Co-authored-by: sonarly-bot --- .../developers/api-keys/SettingsDevelopersApiKeysNew.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeysNew.tsx b/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeysNew.tsx index dc5ad46db6..3b137cf9c0 100644 --- a/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeysNew.tsx +++ b/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeysNew.tsx @@ -21,6 +21,7 @@ import { Section } from 'twenty-ui/layout'; import { CreateApiKeyDocument, GenerateApiKeyTokenDocument, + GetApiKeysDocument, GetRolesDocument, } from '~/generated-metadata/graphql'; import { useNavigateSettings } from '~/hooks/useNavigateSettings'; @@ -58,7 +59,10 @@ export const SettingsDevelopersApiKeysNew = () => { } }, [rolesData]); - const [createApiKey] = useMutation(CreateApiKeyDocument); + const [createApiKey] = useMutation(CreateApiKeyDocument, { + refetchQueries: [GetApiKeysDocument], + awaitRefetchQueries: true, + }); const jotaiStore = useStore();