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 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -13,7 +13,7 @@ const STATS_QUERY = gql`
|
|||||||
}
|
}
|
||||||
teams {
|
teams {
|
||||||
id name iso2 slug
|
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 }
|
goalsByMinute { bucket count }
|
||||||
confederationStats { confederation appearances titles totalGoals }
|
confederationStats { confederation appearances titles totalGoals }
|
||||||
|
|||||||
@@ -7,7 +7,11 @@ let client: InstanceType<typeof ApolloClient> | null = null
|
|||||||
function createClient() {
|
function createClient() {
|
||||||
return new ApolloClient({
|
return new ApolloClient({
|
||||||
link: new HttpLink({ uri: '/api/graphql' }),
|
link: new HttpLink({ uri: '/api/graphql' }),
|
||||||
cache: new InMemoryCache(),
|
cache: new InMemoryCache({
|
||||||
|
typePolicies: {
|
||||||
|
Team: { fields: { stats: { merge: true } } },
|
||||||
|
},
|
||||||
|
}),
|
||||||
defaultOptions: { watchQuery: { fetchPolicy: 'cache-and-network' } },
|
defaultOptions: { watchQuery: { fetchPolicy: 'cache-and-network' } },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user