Complete the code to import the useQuery hook from Apollo Client.
import { [1] } from '@apollo/client';
The useQuery hook is imported from '@apollo/client' to run GraphQL queries in React components.
Complete the code to define a GraphQL query named GET_USERS.
const GET_USERS = gql`query [1] { users { id name } }`;The query name should be a valid GraphQL identifier, typically PascalCase like GetUsers.
Fix the error in the useQuery hook call by filling the blank.
const { loading, error, data } = useQuery([1]);The useQuery hook expects the query document, not a function call or string. So pass GET_USERS without parentheses.
Fill both blanks to destructure loading and error from useQuery and check if loading is true.
const { [1], [2] } = useQuery(GET_USERS);
if ([1]) {
return <p>Loading...</p>;
}We destructure loading and error from the useQuery result. Then check if loading is true to show a loading message.
Fill all three blanks to render user names from data returned by useQuery.
return ( <ul> {data?.users?.map(({ [1], [2] }) => ( <li key=[1]>{ [2] }</li> ))} </ul> );
We destructure id and name from each user object. The id is used as the key, and name is displayed inside the list item.