Below is my simple graph ql hellow rold code which i directly used from graphql official docs toget started, somehow its giving me error: Expected undefined to be a GraphQL schema on hello world
var schema = buildSchema(`
type Query {
hello: String
}
`);
var root = { hello: () => "Hello world!" };
graphql(schema, "{ hello }", root).then((response) => {
console.log(response);
});
Seems the documentation is wrong. It needs to be updated, Can you try updating the code like below?
From
graphql(schema, "{ hello }", root).then((response) => {
console.log(response);
});
To
graphql({
schema: schema,
source: '{ hello }',
rootValue: root
}).then((response) => {
console.log(response);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.