我是 GraphQL 的初学者。在设置服务器、连接到 mongodb 数据库并进行突变时,我在运行后收到以下错误node index.js。
GraphQLError:语法错误:无法解析意外字符“;”。
这是我的index.js...
const { GraphQLServer } = require('graphql-yoga');
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/todo');
const Todo = mongoose.model('Todo',{
text: String,
complete: Boolean
});
const typeDefs = `
type Query {
hello(name: String): String!
}
type Todo{
id: ID!
text: String!
complete: Boolean!
}
type Mutation{
createTodo(text: String!): Todo;
}
;
const resolvers = {
Query: {
hello: (_, { name }) => `Hello ${name || 'World'}`,
},
Mutation: {
createTodo: async (_, { …Run Code Online (Sandbox Code Playgroud)