Complete the code to specify the cache control directive for a GraphQL query.
query GetUser { user(id: 1) @cacheControl(maxAge: [1]) { id name } }The @cacheControl directive uses maxAge to specify cache duration in seconds.
Complete the code to add a cache hint to a GraphQL field resolver.
const resolvers = { Query: { product: (parent, args, context, info) => { info.cacheControl.setCacheHint({ [1]: 120 }); return getProduct(args.id); } } };The setCacheHint method expects an object with maxAge to set cache duration.
Fix the error in the cache control directive usage in this GraphQL schema snippet.
type Query { books: [Book] @cacheControl(maxAge: [1]) }The maxAge value must be a number, not a string or boolean.
Fill both blanks to set cache hints with maxAge and scope in a resolver.
info.cacheControl.setCacheHint({ [1]: 180, [2]: '[3]' });Use maxAge for duration and scope with values like PUBLIC or PRIVATE.
Fill all three blanks to define a cache control directive with maxAge, scope, and inheritMaxAge in a schema.
type Query { latestNews: [News] @cacheControl(maxAge: [1], scope: [2], inheritMaxAge: [3]) }The @cacheControl directive accepts maxAge as a number, scope as 'PUBLIC' or 'PRIVATE', and inheritMaxAge as a boolean.