A. The directive name should be @cacheKey, not @cacheControl
B. The user id must be a string, not a number
C. maxAge value must be a number, not a string
D. The query is missing a required fragment
Solution
Step 1: Check maxAge argument type
maxAge expects a numeric value representing seconds, not a string.
Step 2: Analyze the given value
"thirty" is a string, causing a type error in cacheControl directive.
Final Answer:
maxAge value must be a number, not a string -> Option C
Quick Check:
maxAge needs number, not string = B [OK]
Hint: maxAge must be numeric, no quotes [OK]
Common Mistakes:
Using string instead of number for maxAge
Confusing directive names
Assuming id type causes cache error
5. You want to cache a list of posts but ensure that each post is cached separately by its unique ID. Which cache management strategy should you use in your GraphQL schema?
hard
A. Cache the entire posts list as one entry without keys
B. Use a cache key argument with the post ID to store each post individually
C. Disable caching for posts to always fetch fresh data
D. Set a global cache expiry time for all posts together
Solution
Step 1: Understand caching by unique keys
Caching each post separately requires using a cache key based on post ID.
Step 2: Evaluate options for separate caching
Only Use a cache key argument with the post ID to store each post individually uses cache key argument to store posts individually by ID.
Final Answer:
Use a cache key argument with the post ID to store each post individually -> Option B
Quick Check:
Cache by unique ID key = D [OK]
Hint: Cache items individually using unique keys [OK]