Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 10, 2025

Upgrades Apollo Server from v3 to v4 and replaces micro/microrouter with Express. Implements serverless support using @as-integrations/aws-lambda.

Package changes

Server (src/server.js)

Replaced micro with Express + http.Server:

// Before: micro wrapper with microrouter
module.exports = micro(attachCorsHeaders(catchError(router(...routes))))

// After: Express app with http.Server for test compatibility
const app = express()
app.use(async (req, res, next) => { /* CORS */ })
app.use('/api', express.json(), async (req, res, next) => {
  await apolloServerStarted
  return expressMiddleware(apolloServer, { context: createExpressContext })(req, res, next)
})
module.exports = http.createServer(app)

Serverless (src/serverless.js)

Migrated to Lambda integration with middleware-based CORS:

// Before: apollo-server-lambda with callback-based CORS
apolloServer.createHandler({ expressGetMiddlewareOptions: { cors: { origin } }})

// After: @as-integrations/aws-lambda with middleware
startServerAndCreateLambdaHandler(
  apolloServer,
  handlers.createAPIGatewayProxyEventV2RequestHandler(),
  { context: createServerlessContext, middleware: [/* CORS */] }
)

Apollo Server v4 API changes

  • Created custom httpHeadersPlugin to replace deprecated apollo-server-plugin-http-headers (maintains setCookies/setHeaders in context)
  • Updated landing page plugins: ApolloServerPluginLandingPageLocalDefault for dev, ApolloServerPluginLandingPageProductionDefault for prod
  • Changed context creators to async functions with destructured parameters: async ({ req }) instead of (integrationContext)
  • Updated all type definitions to import gql from graphql-tag instead of apollo-server-micro

Note on versioning

Using Apollo Server v4 (not v5) as @as-integrations/aws-lambda currently only supports v4.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fastdl.mongodb.org
    • Triggering command: node ./postinstall.js (dns block)
    • Triggering command: node /home/REDACTED/work/Ackee/Ackee/node_modules/.bin/ava (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Upgrade Apollo Server (now named @apollo/server) to the latest version. Remove apollo-server-core, apollo-server-lambda and apollo-server-micro, micro, microrouter. Use express and @as-integrations/express5 instead of micro. Ensure that the serverless part still works as it required a new implementation as apollo-server-lambda has been removed.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link

vercel bot commented Nov 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
ackee Ready Ready Preview Comment Nov 10, 2025 7:16am

Copilot AI changed the title [WIP] Upgrade Apollo Server to latest version and remove unnecessary packages Upgrade Apollo Server to v4 and migrate from micro to Express Nov 10, 2025
Copilot AI requested a review from electerious November 10, 2025 07:29
Copilot finished work on behalf of electerious November 10, 2025 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants