Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

233
Vistas
TS newb question: compile error starting Apollo Server trying to resolve promise

Hopefully someone can help with this -- I'm trying to start apollo server in a TypeScript project running Express. My app.ts is below. I am getting the following error:

Argument of type '(value: unknown) => void' is not assignable to parameter of type '() => void'.ts(2769)

I think this has something to do with resolving that last promise to actually start the server. Thanks for answering this presumably very basic question!

import express from 'express';
import { ApolloServer } from 'apollo-server-express';
import depthLimit from 'graphql-depth-limit';
import compression from 'compression';
import cors from 'cors';
import schema from './schema';

const corsConfig = {
    origin: '*',
    credentials: true
};

async function startApolloServer() {
    const server = new ApolloServer({ schema, validationRules: [depthLimit(7)] });
    await server.start();
    const app = express();
    app.use(cors(corsConfig));
    app.use(compression());
    server.applyMiddleware({ app });
    await new Promise(resolve => app.listen({ port: 4000 }, resolve));
    console.log(`🚀 Server ready at http://localhost:4000${server.graphqlPath}`);
  }
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Try the following to match the expected callback signature:

async function startApolloServer() {
    const server = new ApolloServer({ schema, validationRules: [depthLimit(7)] });
    await server.start();
    const app = express();
    app.use(cors(corsConfig));
    app.use(compression());
    server.applyMiddleware({ app });
    await new Promise(resolve => app.listen({ port: 4000 }, (value) => resolve(value)));
    console.log(`🚀 Server ready at http://localhost:4000${server.graphqlPath}`);
}

Hopefully that helps!

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda