0
0
GraphQLquery~20 mins

Refetching and polling in GraphQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Refetching and Polling Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the result of polling with a 5-second interval?

Consider a GraphQL query that fetches the current server time. The client sets up polling with a 5-second interval. What will the client receive?

GraphQL
query GetServerTime {
  serverTime
}

// Client polls every 5 seconds
AThe client receives server time updates randomly, not every 5 seconds.
BThe client receives the same server time repeatedly without updates.
CThe client receives server time only once at the start.
DThe client receives updated server time every 5 seconds.
Attempts:
2 left
💡 Hint

Polling means the client asks the server repeatedly at fixed intervals.

🧠 Conceptual
intermediate
2:00remaining
Why use refetching instead of polling in GraphQL?

Which reason best explains why a developer might choose to use refetching over polling?

ARefetching allows manual control to update data only when needed, saving resources.
BRefetching sends queries continuously at fixed intervals.
CRefetching caches data permanently and never updates it.
DRefetching automatically updates data without any user action.
Attempts:
2 left
💡 Hint

Think about when you want to update data only sometimes, not all the time.

📝 Syntax
advanced
2:00remaining
Which polling setup syntax is correct in Apollo Client?

Choose the correct way to set up polling every 10 seconds in Apollo Client.

GraphQL
const { data, loading, error } = useQuery(GET_DATA, {
  // polling setup here
});
ApollingInterval: 10000
BpollInterval = 10000
CpollInterval: 10000
DpollInterval: '10000'
Attempts:
2 left
💡 Hint

Check the exact property name and value type for polling interval.

🔧 Debug
advanced
2:00remaining
Why does refetching not update data immediately?

A developer calls refetch() on a query, but the UI does not update with new data. What is the most likely cause?

AThe <code>refetch()</code> method is asynchronous and must be awaited.
BThe query is missing a <code>fetchPolicy</code> that allows network requests.
CThe server does not support refetching queries.
DThe query is cached and cannot be updated.
Attempts:
2 left
💡 Hint

Think about how Apollo Client decides where to get data from.

optimization
expert
2:00remaining
How to optimize polling to reduce server load?

You have a GraphQL query polling every 2 seconds, but the server load is too high. Which approach best reduces load while keeping data fresh?

AIncrease polling interval to 30 seconds and use refetch on user actions.
BKeep polling every 2 seconds but disable caching completely.
CUse polling every 2 seconds but add a delay in the server response.
DRemove polling and rely only on initial query load.
Attempts:
2 left
💡 Hint

Think about balancing update frequency and server requests.