Search code examples
node.jsgraphqlapollo-server

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?


Solution

  • @Min Yoongi I too used RestDataSource and I set the headers like this:

    getData(headers){
      return this.get("endpoint", "params block", {
        headers: headers
      })
    }