GithubHelp home page GithubHelp logo

Comments (5)

davidyaha avatar davidyaha commented on May 19, 2024

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.

tomasAlabes avatar tomasAlabes commented on May 19, 2024

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.

davidyaha avatar davidyaha commented on May 19, 2024

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.

tomasAlabes avatar tomasAlabes commented on May 19, 2024

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.

davidyaha avatar davidyaha commented on May 19, 2024

Thanks @tomasAlabes!

from graphql-redis-subscriptions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.