From a6111d7beb5620227696b31403d53df950285251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Sun, 14 Jun 2026 21:12:13 +0200 Subject: [PATCH] fix: resolve Apollo cache warning for TeamStats embedded objects Add merge: true policy for Team.stats so InMemoryCache merges partial TeamStats selections (e.g. search page) with fuller ones (team/stats pages) instead of replacing and losing fields. Also align stats page query to include goalDiff for consistency. Co-Authored-By: Claude Sonnet 4.6 --- app/stats/page.tsx | 2 +- lib/graphql/client.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/stats/page.tsx b/app/stats/page.tsx index 07dd88e..065c2ee 100644 --- a/app/stats/page.tsx +++ b/app/stats/page.tsx @@ -13,7 +13,7 @@ const STATS_QUERY = gql` } teams { id name iso2 slug - stats { appearances titles wins draws losses goalsFor goalsAgainst winPct } + stats { appearances titles wins draws losses goalsFor goalsAgainst goalDiff winPct } } goalsByMinute { bucket count } confederationStats { confederation appearances titles totalGoals } diff --git a/lib/graphql/client.ts b/lib/graphql/client.ts index 463251f..eda090d 100644 --- a/lib/graphql/client.ts +++ b/lib/graphql/client.ts @@ -7,7 +7,11 @@ let client: InstanceType | null = null function createClient() { return new ApolloClient({ link: new HttpLink({ uri: '/api/graphql' }), - cache: new InMemoryCache(), + cache: new InMemoryCache({ + typePolicies: { + Team: { fields: { stats: { merge: true } } }, + }, + }), defaultOptions: { watchQuery: { fetchPolicy: 'cache-and-network' } }, }) }