0
0
GraphQLquery~10 mins

Why server setup enables GraphQL - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a GraphQL schema with a query type.

GraphQL
const schema = new GraphQLSchema({ query: [1] });
Drag options to blanks, or click blank then click option'
AQueryType
BSubscriptionType
CMutationType
DResolverType
Attempts:
3 left
💡 Hint
Common Mistakes
Using MutationType instead of QueryType for the query field.
Leaving the query field undefined.
Confusing subscription with query.
2fill in blank
medium

Complete the code to create a GraphQL server using Express and the graphqlHTTP middleware.

GraphQL
app.use('/graphql', graphqlHTTP({ schema: schema, graphiql: [1] }));
Drag options to blanks, or click blank then click option'
Atrue
Bfalse
Cnull
Dundefined
Attempts:
3 left
💡 Hint
Common Mistakes
Setting graphiql to false disables the helpful interface.
Using null or undefined causes errors.
3fill in blank
hard

Fix the error in the resolver function by completing the return statement.

GraphQL
const root = { hello: () => [1] };
Drag options to blanks, or click blank then click option'
AHello world!
Bconsole.log('Hello world!')
C'Hello world!'
Dreturn 'Hello world!'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes around the string.
Using console.log instead of returning a value.
Including the return keyword inside the arrow function shorthand.
4fill in blank
hard

Fill both blanks to define a GraphQL ObjectType with a name and a field.

GraphQL
const QueryType = new GraphQLObjectType({ name: '[1]', fields: { greeting: { type: [2] } } });
Drag options to blanks, or click blank then click option'
AQuery
BGraphQLString
CGraphQLInt
DMutation
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Mutation' as the name for the query type.
Using GraphQLInt for a text field.
Confusing the type with the name.
5fill in blank
hard

Fill all three blanks to create a GraphQL schema with a query type and a resolver.

GraphQL
const schema = new GraphQLSchema({ [1]: QueryType }); const root = { [2]: () => [3] };
Drag options to blanks, or click blank then click option'
Aquery
Bhello
C'Hello from server!'
Dmutation
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'mutation' instead of 'query' in the schema.
Mismatching resolver names with schema fields.
Not returning a string in the resolver.