diff --git a/packages/twenty-server/src/engine/api/graphql/graphql-config/hooks/use-cached-metadata.ts b/packages/twenty-server/src/engine/api/graphql/graphql-config/hooks/use-cached-metadata.ts index 5aa40c7284f1..3e3be6b1bef5 100644 --- a/packages/twenty-server/src/engine/api/graphql/graphql-config/hooks/use-cached-metadata.ts +++ b/packages/twenty-server/src/engine/api/graphql/graphql-config/hooks/use-cached-metadata.ts @@ -10,8 +10,9 @@ export function useCachedMetadata(config: CacheMetadataPluginConfig): Plugin { const computeCacheKey = (serverContext: any) => { const workspaceId = serverContext.req.workspace?.id ?? 'anonymous'; const cacheVersion = serverContext.req.cacheVersion ?? '0'; + const operationName = getOperationName(serverContext); - return `${workspaceId}:${cacheVersion}`; + return `cachedOperations:${operationName}:${workspaceId}:${cacheVersion}`; }; const getOperationName = (serverContext: any) => @@ -44,6 +45,10 @@ export function useCachedMetadata(config: CacheMetadataPluginConfig): Plugin { if (!cachedResponse) { const responseBody = await response.json(); + if (responseBody.errors) { + return; + } + config.cacheSetter(cacheKey, responseBody); } },