# @as-integrations/koa

> Apollo server integration for koa framework

Latest version **3.0.0** (published 2026-08-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @as-integrations/koa
pnpm add @as-integrations/koa
yarn add @as-integrations/koa
bun add @as-integrations/koa
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2026-08-08 |
| First published | 2022-09-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 0 |
| Unpacked size | 12.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 18 |
| Author | Matt Gordon <matt@greenside.tech> |
| Maintainers | abernix, samchungy, phryneas, mateogordo |
| Keywords | GraphQL, Apollo, Server, Koa, Javascript |

## Links

- npm: https://www.npmjs.com/package/@as-integrations/koa
- Repository: https://github.com/apollo-server-integrations/apollo-server-integration-koa
- Homepage: https://github.com/apollo-server-integrations/apollo-server-integration-koa#readme
- Issues: https://github.com/apollo-server-integrations/apollo-server-integration-koa/issues
- npm.io page: https://npm.io/package/@as-integrations/koa

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2026-08-08
- 2.0.0 — 2026-06-28
- 1.1.1 — 2023-06-06
- 1.1.0 — 2023-06-03
- 1.0.0 — 2023-04-26
- 0.3.0 — 2023-02-20
- 0.2.1 — 2022-11-01
- 0.2.0 — 2022-10-10
- 0.1.0 — 2022-09-27
- 0.0.12 — 2022-09-21

## README

# `@as-integrations/koa`

## A TypeScript/JavaScript GraphQL middleware for `@apollo/server`

## Getting started: Koa middleware

Apollo Server enables the ability to add middleware that lets you run your GraphQL server as part of an app built with Koa, one of the most popular web frameworks for Node.

First, install Apollo Server, the JavaScript implementation of the core GraphQL algorithms, Koa, and two common Koa middleware packages:

```
npm install @as-integrations/koa @apollo/server graphql koa @koa/bodyparser @koa/cors
```

Then, write the following to server.mjs. (By using the .mjs extension, Node lets you use the await keyword at the top level.)

```js
import http from "http";
import Koa from "koa";
import bodyParser from "@koa/bodyparser";
import cors from "@koa/cors";
import { ApolloServer } from "@apollo/server";
import { ApolloServerPluginDrainHttpServer } from "@apollo/server/plugin/drainHttpServer";
import { koaMiddleware } from "@as-integrations/koa";

// The GraphQL schema
const typeDefs = `#graphql
  type Query {
    hello: String
  }
`;

// A map of functions which return data for the schema.
const resolvers = {
  Query: {
    hello: () => "world",
  },
};

const app = new Koa();
const httpServer = http.createServer(app.callback());

// Set up Apollo Server
const server = new ApolloServer({
  typeDefs,
  resolvers,
  plugins: [ApolloServerPluginDrainHttpServer({ httpServer })],
});
await server.start();

app.use(cors());
app.use(bodyParser());
app.use(
  koaMiddleware(server, {
    context: async ({ ctx }) => ({ token: ctx.headers.token }),
  })
);

await new Promise((resolve) => httpServer.listen({ port: 4000 }, resolve));
console.log(`🚀 Server ready at http://localhost:4000`);
```

Now run your server with:

```
node server.mjs
```

Open the URL it prints in a web browser. It will show Apollo Sandbox, a web-based tool for running GraphQL operations. Try running the operation `query { hello }`!

---
_Source: https://npm.io/package/@as-integrations/koa · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
