A GraphQL proxy server which turns your query into real-time live query!
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!
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
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.
Open http://0.0.0.0:1989/altair and run the following query:
subscription TestSubscription {
city(input: { slug: "berlin" }) {
id
name
slug
__typename
}
}
Then you will see the initial subscription data like this.
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!