简体   繁体   中英

Where to check Apollo server express GraphQL cache?

I'm using Apollo Sever Express to build a GraphQL endpoint. As per their documentations, I've added the @cacheControl, the directives in my typeDefs schema. But I'm not sure if it's working, how can I validate or test this situation? I run the server at localhost:3000/graphql (GraphQL ide is opened).

Code-

type Post {
 id: ID!
 title: String
 votes: Int @cacheControl(maxAge: 30)
}

Also tried the dynamic one as well in resolvers, but how/where should I check that?

It depends on what you're after. If you are trying to utilize HTTP caching, you should look at the network calls and see if it sets the cache-control response header. If you want the entire query to be cached, I would simply console.log inside a resolver to see if it is executing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM