# Is there any way to check whether graphql query result is served from cache?

**URL:** <https://community.apollographql.com/t/is-there-any-way-to-check-whether-graphql-query-result-is-served-from-cache/4216>\
**Category:** Client SDKs\
**Tags:** server, web\
**Created:** [August 9, 2022, 9:50am UTC](https://community.apollographql.com/t/is-there-any-way-to-check-whether-graphql-query-result-is-served-from-cache/4216 "2022-08-09T09:50:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sureshdarisa](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@sureshdarisa](https://community.apollographql.com/u/sureshdarisa)\
**Post date:** [August 9, 2022, 9:50am UTC](https://community.apollographql.com/t/is-there-any-way-to-check-whether-graphql-query-result-is-served-from-cache/4216/1 "2022-08-09T09:50:57Z")

</div>

Hi,

We are using apollo graphql in-memory cache. There is a requirement from our client, we want to log the info log when the graphql API is called. We are able to log this in console when the query is executed for first time but after this since the query result is cached and served from cache for subsequent requests we can’t log these requests, is there any way to log if the query result is served from cache.

Regards,  
Suresh

---

<div class="post-metadata">

**Author:** ![hwillson](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/hwillson/32/9_2.png) [@hwillson](https://community.apollographql.com/u/hwillson)\
**Post date:** [August 10, 2022, 12:43pm UTC](https://community.apollographql.com/t/is-there-any-way-to-check-whether-graphql-query-result-is-served-from-cache/4216/2 "2022-08-10T12:43:14Z")

</div>

Hi @sureshdarisa - I would recommend logging through the Apollo Link chain, to make sure you’re only logging requests when they’re being fired off to the network. You can learn more about writing a custom Apollo Link here: [Apollo Link overview - Apollo GraphQL Docs](https://www.apollographql.com/docs/react/api/link/introduction)

---

<div class="post-metadata">

**Author:** ![sureshdarisa](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@sureshdarisa](https://community.apollographql.com/u/sureshdarisa)\
**Post date:** [August 10, 2022, 4:28pm UTC](https://community.apollographql.com/t/is-there-any-way-to-check-whether-graphql-query-result-is-served-from-cache/4216/3 "2022-08-10T16:28:47Z")

</div>

Hi @hwillson

Thanks for the reply.

Actually we are using Apollo GraphQL Server V2 and we are responsible for exposing only server side GraphQL API (only query no mutations). Request is reaching our GraphQl service from frontend like below.

frontend → AggregateService → API g/w → GraphQL API service

So frontend is not making call directly to our graphQL api service via gateway. It is coming from aggregator service which is written in spring boot. Is there anyway we can do the logging at server side in this scenario.

Regards,  
Suresh
