Caching with fragments

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

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.

1 Like

It works!!
Thank you.