Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

226
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda