Comments (5)
Hey @tomasAlabes!
Thanks for your interest and sorry for the lack of examples but for your first question, I think this will work:
mySubscription: {
subscribe: (_, args) => pubsub.asyncIterator(`project.${args.id}.*`, { pattern: true }),
resolve: (payload: any, args, context, info) => {
return payload;
}
}
If that ends up working, would you consider adding that example to the README?
Regarding your second question, I'm afraid there's no elegant way of doing that without changing the way graphql-js
calls the subscriptions resolver. That basically means opening a PR for that.
What is your use case? I wonder if that will be a common enough case to make that change.
from graphql-redis-subscriptions.
Hi @davidyaha, thanks for your response! Indeed your pattern
option worked :) I will create a PR to add it to the readme. Any other option that people should know?
On the 2nd point, in my subscription I send a union of types to the client, so depending on the topic from which I get the message, is the graphql type I'm sending to the client. At the moment I'm sending some metadata in the event itself and from that I create the right gql type. Maybe it's useful to add the topic in the context? Idk. But at least that's my use case.
from graphql-redis-subscriptions.
Glad to hear it worked 🎉
A PR with an example would be great!
As far I understand it should be a PR to graphql-js
so we should define the use case a bit. Basically what we need is a way to push to the AsyncIterable
metadata to be added to something like info variable.
Maybe open a RFC issue on https://github.com/graphql/graphql-js and get some feedback on the idea?
from graphql-redis-subscriptions.
Created the PR with the example. Thanks for the tip.
I will analyze if the RFC is strong enough and maybe ask there what they think.
Keep up the good work :)
from graphql-redis-subscriptions.
Thanks @tomasAlabes!
from graphql-redis-subscriptions.
Related Issues (20)
- GraphQL v16 HOT 2
- Update ioredis HOT 1
- pub/sub type safety improvements
- Ability to dynamically add/remove topics to/from asyncIterator
- Fail to startup with IOREDIS v5.0.5 HOT 1
- When filtering on subscriptions, parameters are always undefined HOT 1
- ID of the payload returned by the subscription is always null | undefined HOT 1
- Getting Type 'Redis' is not assignable to type 'RedisClient' on v2.5.0 HOT 2
- issue with Redis , no construct
- Node Redis Support HOT 2
- pubsub.asyncIterator should return an AsyncIterable
- TS2322: Type 'Redis' is not assignable to type 'RedisClient'. HOT 6
- Support sharded pub/sub
- Error: Connection is closed. with pubsub HOT 1
- Race condition with simultaneous subscribe + quick unsubscribe HOT 9
- Please update Readme.md with required redis ACL perms for cluster HOT 1
- Callback when connection is closed?
- graphql-redis-subscriptions version 2.6.0 is not working with Node 16.0.0 HOT 1
- inside docker graphql-redis-subscriptions searches to connect to localhost HOT 2
- Simple example not working with ioredis 5 due to mismatched types HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-redis-subscriptions.