0
0
GraphQLquery~10 mins

DataLoader batching and caching 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 create a new DataLoader instance.

GraphQL
const userLoader = new DataLoader([1]);
Drag options to blanks, or click blank then click option'
AbatchLoadFn
BmaxBatchSize
CcacheMap
DcacheKeyFn
Attempts:
3 left
💡 Hint
Common Mistakes
Using cacheMap instead of batchLoadFn
Trying to pass maxBatchSize as the first argument
Confusing cacheKeyFn with batchLoadFn
2fill in blank
medium

Complete the code to load a user by ID using DataLoader.

GraphQL
userLoader.[1](userId);
Drag options to blanks, or click blank then click option'
AloadMany
Bclear
CbatchLoadFn
Dload
Attempts:
3 left
💡 Hint
Common Mistakes
Using loadMany when loading a single key
Trying to call batchLoadFn directly
Using clear instead of load
3fill in blank
hard

Fix the error in clearing the cache for a specific key.

GraphQL
userLoader.[1](userId);
Drag options to blanks, or click blank then click option'
AclearAll
Bclear
Cprime
Dload
Attempts:
3 left
💡 Hint
Common Mistakes
Using clearAll to clear a single key
Using prime instead of clear
Calling load instead of clearing
4fill in blank
hard

Fill both blanks to add a new value to the cache and then clear it.

GraphQL
userLoader.[1](userId, userData);
userLoader.[2](userId);
Drag options to blanks, or click blank then click option'
Aprime
Bclear
Cload
DclearAll
Attempts:
3 left
💡 Hint
Common Mistakes
Using load instead of prime to add cache
Using clearAll instead of clear to remove one key
Swapping the order of methods
5fill in blank
hard

Fill all three blanks to batch load multiple keys and then clear the entire cache.

GraphQL
userLoader.[1](userIds);
userLoader.[2]();
userLoader.[3](userId);
Drag options to blanks, or click blank then click option'
AloadMany
BclearAll
Cclear
Dload
Attempts:
3 left
💡 Hint
Common Mistakes
Using load instead of loadMany for multiple keys
Using clear instead of clearAll to clear all cache
Mixing up clear and clearAll