# graphql-subscription-proxy

Latest version **0.0.10** (published 2021-09-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install graphql-subscription-proxy
pnpm add graphql-subscription-proxy
yarn add graphql-subscription-proxy
bun add graphql-subscription-proxy
```

Provides the command `graphql-subscription-proxy`.

## 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.0.10 |
| Published | 2021-09-16 |
| First published | 2021-08-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 16 |
| Unpacked size | 25.5 KB |
| Known vulnerabilities | 0 (+10 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 9 |
| Author | gosho-kazuya |
| Maintainers | acro5piano |

## Links

- npm: https://www.npmjs.com/package/graphql-subscription-proxy
- Repository: https://github.com/acro5piano/graphql-subscription-proxy
- Homepage: https://github.com/acro5piano/graphql-subscription-proxy#readme
- Issues: https://github.com/acro5piano/graphql-subscription-proxy/issues
- npm.io page: https://npm.io/package/graphql-subscription-proxy

## Dependencies (16)

- [got](https://npm.io/package/got.md) ^11.8.2
- [pino](https://npm.io/package/pino.md) ^6.13.2
- [boxen](https://npm.io/package/boxen.md) ^5.1.1
- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [dedent](https://npm.io/package/dedent.md) ^0.7.0
- [fastify](https://npm.io/package/fastify.md) ^3.20.1
- [graphql](https://npm.io/package/graphql.md) ^15.5.1
- [commander](https://npm.io/package/commander.md) ^8.1.0
- [mercurius](https://npm.io/package/mercurius.md) ^8.1.1
- [mqemitter](https://npm.io/package/mqemitter.md) ^4.4.1
- [pino-pretty](https://npm.io/package/pino-pretty.md) ^7.0.0
- [fastify-formbody](https://npm.io/package/fastify-formbody.md) ^5.1.0
- [ts-retry-promise](https://npm.io/package/ts-retry-promise.md) ^0.6.0
- [@sinclair/typebox](https://npm.io/package/@sinclair/typebox.md) ^0.20.4
- [@graphql-tools/wrap](https://npm.io/package/@graphql-tools/wrap.md) ^8.0.9
- [altair-fastify-plugin](https://npm.io/package/altair-fastify-plugin.md) ^4.0.9

## Recent versions

- 0.0.10 (latest) — 2021-09-16
- 0.0.9 — 2021-09-16
- 0.0.8 — 2021-09-15
- 0.0.7 — 2021-09-15
- 0.0.6 — 2021-09-15
- 0.0.4 — 2021-08-11
- 0.0.3 — 2021-08-11
- 0.0.2 — 2021-08-11
- 0.0.1 — 2021-08-11

## README

![test](https://github.com/acro5piano/graphwire/workflows/test/badge.svg)
![release](https://github.com/acro5piano/graphwire/workflows/release/badge.svg)
[![npm version](https://badge.fury.io/js/graphwire.svg)](https://badge.fury.io/js/graphwire)

<p align="center">
    <img width="200" height="200" src="https://raw.githubusercontent.com/acro5piano/graphwire/master/assets/logo.svg">
</p>

# Graphwire

A GraphQL proxy server which turns your query into real-time live query!

# Motivation

GraphQL Subscription is hard to build. It is troublesome and requires lots of work.

- WebSocket connection over a load balancer
- Performance optimization when publishing
- Testing
- Logic duplication among queries and subscriptions
- Initial publish for live query

To solve these problems, `Graphwire` provides a new way: **Proxy GraphQL Queries and make it real-time subscriptions!**

# How it works

![image](https://user-images.githubusercontent.com/10719495/129064036-c70b9afc-be57-4b21-b452-0c40bd7ece57.png)

Benefits:

- No need to write your subscription logic
- No need to prepare Redis instance (for small use-case)
- Use completely the same logic as your Queries

# Try it yourself

### Step 1. Run the proxy server

```
npx graphwire --upstream-url https://api.graphql.jobs
```

Note that https://api.graphql.jobs does not provide Subscription. `graphql-subscription-proxy` forward subscriptions between users and the upstream server.

### Step 2. Subscribe

Open http://0.0.0.0:1989/altair and run the following query:

```graphql
subscription TestSubscription {
  city(input: { slug: "berlin" }) {
    id
    name
    slug
    __typename
  }
}
```

Then you will see the initial subscription data like this.

![image](https://user-images.githubusercontent.com/10719495/133450990-5844fcb7-56aa-4a1b-b0e7-a3f14f14361a.png)

### Step 3. Publish (invalidate)

While keeping the subscription up, open your terminal and run the following command:

```
curl -XPOST http://0.0.0.0:1989/v1/publish -d topic=City:cjuv51m3s00fc0735xosrvscp
```

And you'll see a new subscription is published!

---
_Source: https://npm.io/package/graphql-subscription-proxy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
