Complete the code to enable polling every 5 seconds in a GraphQL query.
const { data, loading, error } = useQuery(GET_USERS, { pollInterval: [1] });The pollInterval option expects milliseconds. To poll every 5 seconds, use 5000.
Complete the code to manually refetch data using the refetch function from useQuery.
const { data, loading, error, [1] } = useQuery(GET_POSTS);
<button onClick={() => [1]()}>Refresh</button>The refetch function allows you to manually reload the query data.
Fix the error in the polling setup by completing the missing option key.
const { data, loading, error } = useQuery(GET_COMMENTS, { [1]: 3000 });The correct option key to enable polling is pollInterval.
Fill both blanks to set up a query with polling and manual refetch.
const { data, loading, error, [1] } = useQuery(GET_MESSAGES, { [2]: 10000 });
<button onClick={() => [1]()}>Reload</button>Use refetch to manually reload data and pollInterval to set polling every 10 seconds.
Fill all three blanks to create a query that polls every 15 seconds, allows manual refetch, and handles loading state.
const { data, [1], error, [2] } = useQuery(GET_NOTIFICATIONS, { [3]: 15000 });
if ([1]) return <p>Loading...</p>;
<button onClick={() => [2]()}>Update</button>loading shows the loading state, refetch reloads data manually, and pollInterval sets polling every 15 seconds.