Complete the code to set a cache control directive for a GraphQL query response.
query GetUser { user(id: 1) @cacheControl(maxAge: [1]) { id name } }The @cacheControl directive uses maxAge to specify how many seconds the response should be cached.
Complete the code to add a cache hint to a GraphQL resolver.
const resolvers = { Query: { user: (parent, args, context) => { context.cacheControl.setCacheHint({ [1]: 120 }); return getUser(args.id); } } };The setCacheHint method expects a maxAge property to define cache duration in seconds.
Fix the error in the cache control directive usage in this GraphQL schema snippet.
type Query { user(id: ID!): User @cacheControl(maxAge: [1]) }The maxAge argument must be a number, not a string or boolean.
Fill both blanks to set cache hints with maxAge and scope in a resolver.
context.cacheControl.setCacheHint({ [1]: 300, scope: '[2]' });The maxAge sets cache duration, and scope defines if cache is public or private.
Fill all three blanks to define a cache control directive with maxAge, scope, and inheritMaxAge.
type Query { posts: [Post] @cacheControl(maxAge: [1], scope: [2], inheritMaxAge: [3]) }maxAge is a number, scope is a string ('PUBLIC' or 'PRIVATE'), and inheritMaxAge is a boolean.