# @mitoai/gintonic-koa

> Koa middleware for gintonic

Latest version **0.2.9** (published 2018-12-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mitoai/gintonic-koa
pnpm add @mitoai/gintonic-koa
yarn add @mitoai/gintonic-koa
bun add @mitoai/gintonic-koa
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.9 |
| Published | 2018-12-20 |
| First published | 2018-12-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 7.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 28 |
| Author | Christian Budde Christensen |
| Maintainers | budde377 |
| Keywords | GraphQL, Koa, Middleware |

## Links

- npm: https://www.npmjs.com/package/@mitoai/gintonic-koa
- Repository: https://github.com/mitoai/gintonic
- Homepage: https://github.com/mitoai/gintonic#readme
- Issues: https://github.com/mitoai/gintonic/issues
- npm.io page: https://npm.io/package/@mitoai/gintonic-koa

## Dependencies (3)

- [http-errors](https://npm.io/package/http-errors.md) ^1.7.1
- [express-graphql](https://npm.io/package/express-graphql.md) ^0.7.1
- [@mitoai/gintonic](https://npm.io/package/@mitoai/gintonic.md) ^0.2.8

## 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

- 0.2.9 (latest) — 2018-12-20
- 0.2.7-alpha.0 (canary) — 2018-12-18
- 0.2.8 — 2018-12-20
- 0.2.7 — 2018-12-18
- 0.2.6 — 2018-12-18
- 0.2.5 — 2018-12-15
- 0.2.5-alpha.1 — 2018-12-15
- 0.2.4 — 2018-12-14
- 0.2.3 — 2018-12-14
- 0.2.2 — 2018-12-14
- 0.2.1 — 2018-12-14
- 0.2.1-alpha.7 — 2018-12-14
- 0.2.1-alpha.6 — 2018-12-14
- 0.2.1-alpha.5 — 2018-12-12
- 0.2.1-alpha.4 — 2018-12-12
- … 3 more at https://npm.io/package/@mitoai/gintonic-koa/versions

## README

# GraphQL Transformer Koa-middleware

Start using GraphQL Transformer with the koa middleware. 

## Getting started
Install the koa middleware
```bash
npm i @mitoai/gintonic-koa
```

By providing
a schema and transformation (as a string), and a fetcher for executing
source queries, this middleware will expose a GraphQL target
Api returing data from the source API.

```javascript
const Koa = require('koa')
const Router = require('koa-router')
const gt = require('@mitoai/gintonic-koa')
const fetch = require('node-fetch')

const upstreamUrl = "https://example.com/graphql"
const transformationString = "transform schema { query }"

const app = new Koa()

// Execute source query against source API
async function fetcher ({query, variables, operationName, ctx}) {
  const res = await fetch(upstreamUrl, {
    method: "POST",
    body: JSON.stringify({query, variables, operationName}),
    headers: {
      'Content-Type': 'application/json'
    }
  })
  return res.json()
}

const router = new Router()
router.all('/graphql', gt({
  upstreamUrl,
  transformation: transformationString,
  fetcher
}))

app.use(router.routes()).use(router.allowedMethods())

app.listen(1337)

```

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