问题描述
问题总结
我是 GraphQL 世界的新手,我正在使用初学者脚本来启动服务器并访问本地主机上的游乐场。当我访问它时,我看到一个空白页面,其中包含单词 EOF
作为纯文本(文件结尾)。
我的尝试
- Unexpected while using graphql ,虽然这是查询创建过程中的错误(在我的情况下,我根本看不到操场)
索引js
import { GraphQLServer } from 'graphql-yoga'
//Type DeFinitions (Schema)
const typeDefs = `
type Query {
hello: String!
}
`
//Resolvers
const resolvers = {
Query: {
hello(){
return 'This is my first query!'
}
}
}
const server = new GraphQLServer({
typeDefs,resolvers
})
server.start(()=>{
console.log(`server is up on: ${server.options.port}`)
})
控制台输出
server is up on: 4000
Web 浏览器输出
我的 package.json
{
"name": "graphql-basics","version": "1.0.0","description": "","main": "index.js","scripts": {
"start": "babel-node src/index.js","test": "echo \"Error: no test specified\" && exit 1"
},"author": "","license": "ISC","dependencies": {
"babel-cli": "^6.26.0","babel-preset-env": "^1.7.0","graphql-yoga": "^1.14.10"
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)