Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

232
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!