# Caching with fragments

**URL:** <https://community.apollographql.com/t/caching-with-fragments/7093>\
**Category:** Client SDKs\
**Tags:** client, web\
**Created:** [January 3, 2024, 7:02am UTC](https://community.apollographql.com/t/caching-with-fragments/7093 "2024-01-03T07:02:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sachin](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/sachin/32/4667_2.png) [@Sachin](https://community.apollographql.com/u/Sachin)\
**Post date:** [January 3, 2024, 7:02am UTC](https://community.apollographql.com/t/caching-with-fragments/7093/1 "2024-01-03T07:02:10Z")

</div>

So, I have a query written like this:  
const assetsQuery = gql` query getAssets($filters: AssetsDefaultFilters!) { assets(filters: $filters) { ... on BaseAsset { address geoLocation { lat: latitude lng: longitude } id name } ... on Hotel { id noOfKeys salesData { price pricePerRoom } } ... on Logistics { area id occupancy leases { area id } rentGross rentPu } } }`;

And here:  
const response = await client.query({  
fetchPolicy: “cache-first”,  
query: assetsQuery,  
variables: {  
filters: filters,  
},  
});

But when I look into the cache, BaseAsset fragment is not cached. But everything else is working fine.  
So,  
{  
address  
geoLocation {  
lat: latitude  
lng: longitude  
}  
id  
name  
}

There values are not there but rest of the object is there,  
Any idea why it might be happening?  
Thank you

---

<div class="post-metadata">

**Author:** ![lenz](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/lenz/32/4007_2.png) [@lenz](https://community.apollographql.com/u/lenz)\
**Post date:** [January 3, 2024, 9:42am UTC](https://community.apollographql.com/t/caching-with-fragments/7093/2 "2024-01-03T09:42:00Z")

</div>

If the server returns a different `__typename` for that fragment than `BaseAsset` (which the name kinda implies), you have to use `possibleTypes`, as [described here in the fragment documentation](https://www.apollographql.com/docs/react/data/fragments/#using-fragments-with-unions-and-interfaces).

---

<div class="post-metadata">

**Author:** ![Sachin](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/sachin/32/4667_2.png) [@Sachin](https://community.apollographql.com/u/Sachin)\
**Post date:** [January 3, 2024, 10:23am UTC](https://community.apollographql.com/t/caching-with-fragments/7093/3 "2024-01-03T10:23:02Z")

</div>

It works!!  
Thank you.
