Apollo Server 5.5

Last reviewed Sep 6, 2026

Export as PDF

Prompt Details

Prompt Composition

4prompts
  1. JavaScript ES2026102 lines · 3.1K tokens
  2. Node.js 24101 lines · 5.3K tokens
  3. TypeScript 746 lines · 1.5K tokens
  4. Apollo Server 5.557 lines · 1.5K tokens
Total306 lines · 11.5K tokens

CWE Coverage

  • 20
  • 22
  • 59
  • 73
  • 78
  • 79
  • 88
  • 89
  • 95
  • 113
  • 117
  • 200
  • 203
  • 208
  • 209
  • 214
  • 250
  • 287
  • 295
  • 297
  • 319
  • 323
  • 330
  • 338
  • 346
  • 347
  • 352
  • 354
  • 362
  • 367
  • 377
  • 426
  • 444
  • 459
  • 471
  • 488
  • 494
  • 502
  • 524
  • 532
  • 602
  • 613
  • 614
  • 639
  • 653
  • 732
  • 770
  • 807
  • 829
  • 838
  • 862
  • 863
  • 908
  • 915
  • 916
  • 918
  • 922
  • 942
  • 943
  • 1004
  • 1275
  • 1321
  • 1333

Prompt Preview

Apply the Node.js 24, TypeScript 7, and JavaScript ES2026 prompts first. When Apollo Server runs in Express through expressMiddleware, also apply the Express prompt for its installed version. These rules cover Apollo Server 5.5 context, credential lifetime, resolvers, authorization, schema exposure, query cost, CSRF prevention, CORS, errors, plugins, and deployment.

Context and authentication

  • Authenticate each HTTP request and subscription operation before constructing privileged context values.
  • Apollo Server has no session or login API, and it calls context once per HTTP request. Check the session or token there against server-side state, not just its signature and expiry, so a logout or revocation takes effect on the next operation.
  • Derive principal, tenant, roles, and data loaders from verified credentials rather than request arguments or headers alone.
  • Create request-scoped context and data loaders so cached objects cannot cross users or tenants.
  • Keep credentials, database clients, and internal service objects out of resolver return values and error extensions.
  • Subscriptions outlive the checks that admitted them: graphql-ws runs onConnect once per socket and useServer's context once per subscription, never per event, and an open socket can't take new connectionParams. Close the socket with ctx.extra.socket.close(4403, 'Forbidden') when its token expires, its session is revoked, or the user logs out, so the client reconnects with fresh credentials, and recheck access per event in a withFilter filter, which receives contextValue as its