fix: include payload in TPA query key to prevent stale cache

The query key only included pageId, so if the payload (tpa_hint, query
params, etc.) changed while pageId stayed the same, React Query would
serve stale cached data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Adolfo R. Brandes
2026-03-06 19:27:51 -03:00
committed by Adolfo R. Brandes
parent bb3ab6cba4
commit e52d3d89fd
2 changed files with 2 additions and 2 deletions

View File

@@ -7,7 +7,7 @@ import { ThirdPartyAuthQueryKeys } from './queryKeys';
export const THIRD_PARTY_AUTH_ERROR = 'third-party-auth-error';
const useThirdPartyAuthHook = (pageId, payload) => useQuery({
queryKey: ThirdPartyAuthQueryKeys.byPage(pageId),
queryKey: ThirdPartyAuthQueryKeys.byPage(pageId, payload),
queryFn: () => getThirdPartyAuthContext(payload),
retry: false,
staleTime: 5 * 60 * 1000, // 5 minutes — TPA context is effectively static per session

View File

@@ -2,5 +2,5 @@ import { appId } from '../../constants';
export const ThirdPartyAuthQueryKeys = {
all: [appId, 'ThirdPartyAuth'] as const,
byPage: (pageId: string) => [appId, 'ThirdPartyAuth', pageId] as const,
byPage: (pageId: string, payload?: unknown) => [appId, 'ThirdPartyAuth', pageId, payload] as const,
};