我遇到以下语法错误:
throw(0,_syntaxError.syntaxError)(this._lexer.source,token.start, “预期的” .concat(种类,“,找到的”).concat(getTokenDesc(token)));
这是我的模式:
app.use('/graphql', graphqlHTTP({
schema: buildSchema('type RootQuery{' +
'events: [String!]!' +
'}' +
'type RootMutation{' +
'createEvent(name: String): String' +
'}' +
'schema{' +
'query: RootQuery' +
'mutation: RootMutation' +
'}'),
rootValue: {
events: () =>{
return ['Hello1','Hello2','Hello3'];
},
createEvent: (args)=>{
const eventName = args.name;
return eventName;
}
},
graphiql: true,
}));
我试图花几个小时来了解在模式语法中我哪里写错了,但找不到。
答案 0 :(得分:0)
我缺少一些逗号。
这是工作代码:
app.use('/graphql', graphqlHTTP({
schema: buildSchema('type RootQuery{' +
'events: [String!]!' +
'},' +
'type RootMutation{' +
'createEvent(name: String): String' +
'},' +
'schema{' +
'query: RootQuery,' +
'mutation: RootMutation' +
'}'),
rootValue: {
events: () =>{
return ['Hello1','Hello2','Hello3'];
},
createEvent: (args)=>{
const eventName = args.name;
return eventName;
}
},
graphiql: true
}));