Skip to content

Commit

Permalink
Update running-an-express-graphql-server.mdx
Browse files Browse the repository at this point in the history
Issue
The server throws an error because the root variable is not defined. The correct variable name should be rootValue, which was previously declared in the code.

Fix
Updated rootValue in the createHandler function to use the correct variable name.

Changes
Replaced root with rootValue in the GraphQL handler configuration.
This fix ensures that the GraphQL API properly resolves queries.
  • Loading branch information
fto-dev authored Feb 26, 2025
1 parent 7066b58 commit c59e83b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions website/pages/docs/running-an-express-graphql-server.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const express = require('express');
// Construct a schema, using GraphQL schema language
const schema = buildSchema(`type Query { hello: String } `);

// The rootValue provides a resolver function for each API endpoint
const rootValue = {
// The root provides a resolver function for each API endpoint
const root = {
hello() {
return 'Hello world!';
},
Expand Down Expand Up @@ -63,8 +63,8 @@ const schema = new GraphQLSchema({
}),
});
// The rootValue provides a resolver function for each API endpoint
const rootValue = {
// The root provides a resolver function for each API endpoint
const root = {
hello() {
return 'Hello world!';
},
Expand Down

0 comments on commit c59e83b

Please sign in to comment.