0
0
GraphQLquery~10 mins

Cache management in GraphQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the cache control directive for a GraphQL query.

GraphQL
query GetUser { user(id: 1) @cacheControl(maxAge: [1]) { id name } }
Drag options to blanks, or click blank then click option'
A60
Bnull
C"max-age"
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using boolean values instead of a number for maxAge.
Putting maxAge value in quotes.
2fill in blank
medium

Complete the code to add a cache hint to a GraphQL field resolver.

GraphQL
const resolvers = { Query: { product: (parent, args, context, info) => { info.cacheControl.setCacheHint({ [1]: 120 }); return getProduct(args.id); } } };
Drag options to blanks, or click blank then click option'
Acache
Bttl
Cduration
DmaxAge
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect property names like 'cache' or 'ttl'.
Passing a string instead of a number for maxAge.
3fill in blank
hard

Fix the error in the cache control directive usage in this GraphQL schema snippet.

GraphQL
type Query { books: [Book] @cacheControl(maxAge: [1]) }
Drag options to blanks, or click blank then click option'
Atrue
B"300"
C300
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the number in quotes making it a string.
Using boolean values instead of a number.
4fill in blank
hard

Fill both blanks to set cache hints with maxAge and scope in a resolver.

GraphQL
info.cacheControl.setCacheHint({ [1]: 180, [2]: '[3]' });
Drag options to blanks, or click blank then click option'
AmaxAge
Bscope
CPUBLIC
DPRIVATE
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect keys like 'cache' or 'duration'.
Using lowercase or misspelled scope values.
5fill in blank
hard

Fill all three blanks to define a cache control directive with maxAge, scope, and inheritMaxAge in a schema.

GraphQL
type Query { latestNews: [News] @cacheControl(maxAge: [1], scope: [2], inheritMaxAge: [3]) }
Drag options to blanks, or click blank then click option'
A120
BPUBLIC
Ctrue
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around numeric values.
Using lowercase for scope values.
Using strings instead of booleans for inheritMaxAge.