[英]“Syntax Error: Expected Name, found \”)\“.”,
I'm new to graphql and js in general,trying to build as many exercises as I can to learn.我是 graphql 和一般 js 的新手,尝试构建尽可能多的练习来学习。 I did the following:
我做了以下事情:
var schema = buildSchema(`
type Query{
events(): Message
}
type Message{
id: ID!
random_nr: Int!
}`);
class Message {
calculate(){
var output = [];
var id = Math.random().toString();
var random_nr = Math.floor(Math.random() * 10);
output.push(id);
output.push(random_nr);
return output;
console.log(output);
};
}
var root = { events:()=>{ return new Message(); }}
and then in the browser I do:然后在浏览器中我这样做:
{
events(){
calculate()
}
}
receive the title error, can someone shine the light of wisdom into me.收到标题错误,有人可以将智慧之光照射到我身上。
update : after adding ()
to events now I receive:更新:将
()
添加到事件后,我现在收到:
{
"message": "Failed to fetch",
"stack": "TypeError: Failed to fetch"
}
correct answer:正确答案:
var schema = buildSchema(`
type Message{
calculate: [Int]
}
type Query{
events: Message
} `);
and in the browser you remove all () where there are no args!并在浏览器中删除所有没有参数的 () !
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.