[英]Where to check Apollo server express GraphQL cache?
I'm using Apollo Sever Express to build a GraphQL endpoint.我正在使用 Apollo Sever Express 构建 GraphQL 端点。 As per their documentations, I've added the @cacheControl, the directives in my typeDefs schema.
根据他们的文档,我在我的 typeDefs 架构中添加了 @cacheControl 指令。 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).
我在 localhost:3000/graphql 运行服务器(GraphQL ide 已打开)。
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.如果您尝试使用 HTTP 缓存,您应该查看网络调用并查看它是否设置了
cache-control
响应 header。 If you want the entire query to be cached, I would simply console.log
inside a resolver to see if it is executing.如果您希望缓存整个查询,我只需在解析器中使用
console.log
来查看它是否正在执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.