0
0
GraphQLquery~10 mins

Apollo Server 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 ApolloServer from the correct package.

GraphQL
const { [1] } = require('apollo-server');
Drag options to blanks, or click blank then click option'
AGraphQLServer
BServerApollo
CApolloServer
DApolloClient
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ApolloClient' instead of 'ApolloServer'.
Misspelling the class name.
2fill in blank
medium

Complete the code to define a simple type definition for a Query named 'hello'.

GraphQL
const typeDefs = `type Query { [1]: String }`;
Drag options to blanks, or click blank then click option'
Ahello
Bhi
Cwelcome
Dgreet
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different field name like 'greet' or 'hi'.
Forgetting the colon and type.
3fill in blank
hard

Fix the error in the resolver function to return the string 'Hello world!'.

GraphQL
const resolvers = { Query: { hello: () => [1] } };
Drag options to blanks, or click blank then click option'
A'Hello world!'
BHello world!
C"Hello world!"
Dreturn 'Hello world!'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes around the string.
Using 'return' inside an arrow function without braces.
4fill in blank
hard

Fill both blanks to create and start the Apollo Server with typeDefs and resolvers.

GraphQL
const server = new [1]({ typeDefs, [2] });
server.listen().then(({ url }) => {
  console.log(`Server ready at ${url}`);
});
Drag options to blanks, or click blank then click option'
AApolloServer
BApolloClient
Cresolvers
Dresolver
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ApolloClient' instead of 'ApolloServer'.
Passing 'resolver' instead of 'resolvers'.
5fill in blank
hard

Fill all three blanks to import ApolloServer, define a Query type, and create the server.

GraphQL
const { [1] } = require('apollo-server');

const typeDefs = `type Query { [2]: String }`;

const resolvers = { Query: { [3]: () => 'Hello!' } };

const server = new ApolloServer({ typeDefs, resolvers });
server.listen().then(({ url }) => console.log(`Running at ${url}`));
Drag options to blanks, or click blank then click option'
AApolloServer
Bhello
DQuery
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for the Query field and resolver.
Misspelling 'ApolloServer' in the import.