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?
query GetServerTime {
serverTime
}
// Client polls every 5 secondsPolling means the client asks the server repeatedly at fixed intervals.
Polling with a 5-second interval means the client sends the query every 5 seconds and receives the latest server time each time.
Which reason best explains why a developer might choose to use refetching over polling?
Think about when you want to update data only sometimes, not all the time.
Refetching is a manual or event-triggered way to update data, which helps avoid unnecessary network requests compared to polling.
Choose the correct way to set up polling every 10 seconds in Apollo Client.
const { data, loading, error } = useQuery(GET_DATA, { // polling setup here });
Check the exact property name and value type for polling interval.
The correct property is pollInterval with a number value in milliseconds.
A developer calls refetch() on a query, but the UI does not update with new data. What is the most likely cause?
Think about how Apollo Client decides where to get data from.
If the fetch policy is set to only use cache, refetching won't trigger a network request to get fresh data.
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?
Think about balancing update frequency and server requests.
Increasing the polling interval reduces requests, and refetching on user actions keeps data fresh when needed.