Goal: when arquiring some data (a big list = prefetch) and later quering a subset of that list (by extId), I want the data to be acquired from cache (iso http req).
Situation: supabase + pg_graphql (adds intermediate fields like adsCollection, edges, node to e.g. support pagination, which are not stored in normalized form in cache)+ (vue) apollo client
Query:
query getAdGroupingData($adExtIds: [UUID]) {
**adsCollection**(
filter: { extId: { in: $adExtIds } }
) {
**edges** {
**node** { -->typename = ads
extId
name
creatives{ -->typename is creatives
thumbnailUrl, extId}
}
}
}
execution query first 1) with variables adExtIds = [1,2,3] and later with 2) [1,2] should result in only ONE network call. But currently getting 2 calls.
Tried:
- I’m able to get the normalized ads and creatives in cache [OK]
typePolicies: {
ads: { keyFields: ['extId'] },
creatives: { keyFields: ['extId'] },
- able to get a single entry from cache, but undesired as I need to write a second query/ fragment and post processer to get the correct fields later.
client.readFragment({
id: 'ads:{"extId":"23853221171040758"}', // The value of the to-do item's cache ID
fragment: gql`
fragment AdGroupData on ads {
extId
name
creatives {
thumbnailUrl
extId
}
}
`,
3. problem, how to just execute the ‘getAdGroupingData’ query with a subset of the id’s without performing a network request