https://github.com/acro5piano/graphwire
Pusher for GraphQL; A GraphQL proxy server which turns your query into real-time live query!
https://github.com/acro5piano/graphwire
graphql graphql-subscriptions live-queries nodejs proxy realtime typescript websockets
Last synced: 8 months ago
JSON representation
Pusher for GraphQL; A GraphQL proxy server which turns your query into real-time live query!
- Host: GitHub
- URL: https://github.com/acro5piano/graphwire
- Owner: acro5piano
- Created: 2021-08-11T12:16:39.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-10-27T02:17:45.000Z (over 4 years ago)
- Last Synced: 2025-01-31T22:25:38.394Z (over 1 year ago)
- Topics: graphql, graphql-subscriptions, live-queries, nodejs, proxy, realtime, typescript, websockets
- Language: TypeScript
- Homepage: https://graphwire.netlify.app
- Size: 330 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README


[](https://badge.fury.io/js/graphwire)
# 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

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.

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