apollographql / apollographql/fullstack-tutorial

Getting error when first starting server in the tutorial

Abierto
#70 6 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
1.2k
Forks
808
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Comienza con schema.js e inspecciona el literal de plantilla gql comparándolo con las definiciones de tipos que se muestran en el tutorial; después, revisa index.js para confirmar cómo se carga el esquema. Inicia el servidor y verifica que el tutorial se inicie sin el SyntaxError informado.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, node.js
Área
api, backend
Tipo de issue
Error
Dificultad
1/5
Tiempo estimado
Menos de una hora
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.