Complete the code to define a GraphQL schema with a query type.
const schema = new GraphQLSchema({ query: [1] });The query field defines the entry point for reading data in GraphQL. It must be set to the query type object.
Complete the code to create a GraphQL server using Express and the graphqlHTTP middleware.
app.use('/graphql', graphqlHTTP({ schema: schema, graphiql: [1] }));
Setting graphiql to true enables the GraphiQL interface, which helps test queries in the browser.
Fix the error in the resolver function by completing the return statement.
const root = { hello: () => [1] };The resolver must return a string value. The string needs quotes to be valid.
Fill both blanks to define a GraphQL ObjectType with a name and a field.
const QueryType = new GraphQLObjectType({ name: '[1]', fields: { greeting: { type: [2] } } });The object type name is usually 'Query' for the root query. The field type for text is GraphQLString.
Fill all three blanks to create a GraphQL schema with a query type and a resolver.
const schema = new GraphQLSchema({ [1]: QueryType }); const root = { [2]: () => [3] };The schema needs a query field set to the query type. The resolver function named hello returns a greeting string.