apollographql / apollographql/fullstack-tutorial

Getting error when first starting server in the tutorial

オープン
#70 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
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 を確認して、スキーマがどのように読み込まれるかを確かめます。サーバーを起動し、報告されている SyntaxError なしでチュートリアルが開始することを検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, node.js
領域
api, backend
issue の種類
バグ
難易度
1/5
見積もり時間
1時間未満
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。