Errors after installing GraphQL Yoga
我试图按照Edureka https://www.youtube.com/watch?v=rpJO0T08Bnc的教程视频学习,并使用其他说明在Ubuntu上进行安装。发生了严重错误,因为我无法在localhost:4000上访问该应用程序。 任何帮助将不胜感激。
答案 0 :(得分:0)
您创建服务器了吗?让我跟随。
yarn add graphql-yoga
或npm install graphql-yoga --save
{
"presets": [ "env", "stage-3" ]
}
create the index.js
并添加
`import { GraphQLServer } from 'graphql-yoga';
import resolvers from './graphql/resolvers'
const server = new GraphQLServer({
typeDefs: "./graphql/schema.graphql",
resolvers: resolvers
});
server.start(() => console.log("Graphql Server Running "));`
这是我的package.json。遵循此“脚本”
{
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"graphql-yoga": "^1.16.7"
},
"scripts": {
"start": "nodemon --exec babel-node index.js"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-3": "^6.24.1"
}
}
这些是我的“ Initail创建GraphQL瑜伽设置”