0.0.10 • Published 3 years ago
graphql-subscription-proxy v0.0.10
graphql-subscription-proxy
experimental Turn your query into real-time live query.
Try it yourself
Step 1. Run server
npx graphql-subscription-proxy --port 8000 --upstream-url https://rickandmortyapi.com/graphql
Thank you for https://rickandmortyapi.com for providing the quick testing environment
Step 2. Subscribe
Any client which supports subscriptions-transports-ws
is okay, but I recommend to use Altair to test it.
For testing, please run the following subscription:
subscription {
episode(id: 1) {
id
name
__typename
}
}
Soon, you can get see the subscription result like this. Note that the schema is not configured to use Subscriptions, but it works thanks to our proxy!
Step 3. Publish (invalidate)
Keep subscription open and open your terminal, then run the following command:
curl -XPOST http://0.0.0.0:8000/v1/publish -H 'content-type: application/json' -d '{"topic": "Episode:1"}'
And you'll see the new subscription is published!