简体   繁体   English

在哪里查看 Apollo 服务器 express GraphQL 缓存?

[英]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.

相关问题 Apollo Server Express + GraphQL关系 - Apollo Server Express + GraphQL relationships 为什么要在服务器上缓存 graphql 字段。 (阿波罗服务器) - Why to cache graphql fields on server. ( apollo-server ) Apollo GraphQL 服务器 - 从缓存插件访问查询参数 - Apollo GraphQL Server - Access query params from cache plugin Apollo-server-express 返回“无法获取 /”而不是 Graphql 游乐场 - Apollo-server-express returning “cannot Get /” instead of the Graphql playground 缺少 GET 查询:在 Express 服务器上使用 Apollo 实现 GraphQL - GET query missing: Implementing GraphQL Using Apollo On an Express Server res.session 未定义 graphql apollo-server-express - res.session undefined graphql apollo-server-express apollo server 和 express-graphql 有什么区别 - What is the difference between apollo server and express-graphql 使用ApolloClient和Apollo-Server-Express进行GraphQL错误处理 - GraphQL Error Handling with ApolloClient and Apollo-Server-Express 我可以在没有 Apollo Server 的情况下使用 Apollo Client 吗? 我有一个普通的 GraphQl express 服务器并且想要与前端 ReactJS 集成 - I can use Apollo Client without Apollo Server? I have a plain GraphQl express server and want to integrate with front-end ReactJS Apollo GraphQL Server 中的标量指令 - Directives on scalars in Apollo GraphQL Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM