0
0
GraphQLquery~10 mins

Apollo Client setup 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 import the ApolloClient class.

GraphQL
import { [1] } from '@apollo/client';
Drag options to blanks, or click blank then click option'
AApolloClient
BReact
CGraphQL
DuseQuery
Attempts:
3 left
💡 Hint
Common Mistakes
Importing React instead of ApolloClient.
Using useQuery which is for queries, not client setup.
2fill in blank
medium

Complete the code to set the URI for the Apollo Client.

GraphQL
const client = new ApolloClient({ uri: '[1]' });
Drag options to blanks, or click blank then click option'
Alocalhost
Bgraphql
Chttp://localhost:4000/graphql
Dhttp://api
Attempts:
3 left
💡 Hint
Common Mistakes
Using just 'localhost' without protocol or path.
Missing the '/graphql' path.
3fill in blank
hard

Fix the error in the code to create the Apollo Client with cache.

GraphQL
const client = new ApolloClient({ uri: 'http://localhost:4000/graphql', cache: new [1]() });
Drag options to blanks, or click blank then click option'
AHttpLink
BInMemoryCache
CApolloProvider
DGraphQLClient
Attempts:
3 left
💡 Hint
Common Mistakes
Using HttpLink instead of cache.
Using ApolloProvider which is a React component.
4fill in blank
hard

Fill both blanks to import and use ApolloProvider in React.

GraphQL
import { ApolloClient, [1] } from '@apollo/client';

function App() {
  return (
    <[2] client={client}>
      {/* Your app components */}
    </[2]>
  );
}
Drag options to blanks, or click blank then click option'
AApolloProvider
BuseQuery
DQuery
Attempts:
3 left
💡 Hint
Common Mistakes
Using useQuery instead of ApolloProvider.
Not wrapping the app with ApolloProvider.
5fill in blank
hard

Fill all three blanks to create a complete Apollo Client setup with cache and provider.

GraphQL
import { ApolloClient, [1], [2] } from '@apollo/client';

const client = new ApolloClient({
  uri: '[3]',
  cache: new InMemoryCache()
});
Drag options to blanks, or click blank then click option'
AInMemoryCache
BApolloProvider
CHttpLink
DApolloClient
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing HttpLink with InMemoryCache.
Not importing ApolloProvider when using React.