apollographql / apollographql/fullstack-tutorial
Getting error when first starting server in the tutorial
- 主要语言
- TypeScript
- 星标
- 1.2k
- 派生
- 808
- PR 合并指标
- 30 天内没有已合并 PR
描述
I'm sure it's something I'm doing wrong, but I've just started the tutorial and when I first try to start the server I get
> type Launch {
> ^^^^^^
>
> SyntaxError: Unexpected identifier
> at new Script (vm.js:74:7)
> at createScript (vm.js:246:10)
> at Object.runInThisContext (vm.js:298:10)
> at Module._compile (internal/modules/cjs/loader.js:657:28)
> at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
> at Module.load (internal/modules/cjs/loader.js:599:32)
> at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
> at Function.Module._load (internal/modules/cjs/loader.js:530:3)
> at Module.require (internal/modules/cjs/loader.js:637:17)
> at require (internal/modules/cjs/helpers.js:20:18)
> [nodemon] app crashed - waiting for file changes before starting...
My `schema.js` file is
```
const { gql } = require('apollo-server');
const typeDefs = gql``
module.exports = typeDefs;
type Launch {
id: ID!
site: String
mission: Mission
rocket: Rocket
isBooked: Boolean!
}
type Rocket {
id: ID!
name: String
type: String
}
type User {
id: ID!
email: String!
trips: [Launch]!
}
type Mission {
name: String
missionPatch(size: PatchSize): String
}
enum PatchSize {
SMALL
LARGE
}
type Mutation {
# if false, booking trips failed -- check errors
bookTrips(launchIds: [ID]!): TripUpdateResponse!
# if false, cancellation failed -- check errors
cancelTrip(launchId: ID!): TripUpdateResponse!
login(email: String): String # login token
}
type Query {
launches: [Launch]!
launch(id: ID!): Launch
# Queries for the current user
me: User
}
```
and `index.js` is
```
const { ApolloServer } = require('apollo-server');
const typeDefs = require('./schema');
const server = new ApolloServer({ typeDefs });
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});
```
Not sure where the error lies as I was simply copying code from the tutorial....thanks for any clues.
贡献指南
这个仓库没有索引到贡献指南
调研方向
从 schema.js 开始,将 gql 模板字面量与教程中显示的类型定义进行对照检查;然后检查 index.js,以确认 schema 是如何加载的。运行服务器并验证教程能够在没有报告的 SyntaxError 的情况下启动。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, node.js
- 领域
- api, backend
- Issue 类型
- 缺陷
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100