【发布时间】:2019-06-28 15:42:07
【问题描述】:
我正在关注如何使用 graphql 教程,我将在其中设置一个简单的 graphql 服务器。
index.js
const { GraphQLServer } = require('graphql-yoga');
// 1
let links = [{
id: 'link-0',
url: 'www.howtographql.com',
description: 'Fullstack tutorial for GraphQL'
}];
const resolvers = {
Query: {
info: () => `This is the API of a Hackernews Clone`,
// 2
feed: () => links,
},
// 3
Link: {
id: (parent) => parent.id,
description: (parent) => parent.description,
url: (parent) => parent.url,
}
};
// 3
const server = new GraphQLServer({
typeDefs:'./schema.graphql',
resolvers,
});
server.start(() => console.log(`Server is running on http://localhost:4000`));
如您所见,我在创建 GraphQLServer 时引用了我的架构文件。但是,当我运行服务器时,出现以下错误:
/Users/BorisGrunwald/Desktop/programmering/Javascript/GraphQL/hackernews-node/node_modules/graphql-yoga/dist/index.js:418
throw new Error("No schema found for path: " + schemaPath);
^
我的文件结构:
谁能发现错误?
【问题讨论】:
标签: javascript node.js graphql