Giter Club home page Giter Club logo

Comments (4)

ujwal-setlur avatar ujwal-setlur commented on August 28, 2024

This is a bit of a critical issue for me, so any help will be greatly appreciated. Thanks!

from apollo.

ujwal-setlur avatar ujwal-setlur commented on August 28, 2024

OK, I think it is explained here:

https://github.com/cult-of-coders/apollo-live-server

The current limitation is that the reactive events dispatched by this publication are only at Notification level in the database, but what happens when we want to also send down the pipe relational info, such as, Task linked to Notification by taskId, how can we handle this ?

from apollo.

ujwal-setlur avatar ujwal-setlur commented on August 28, 2024

OK, I solved it by enhancing the resolver for the subscription:

  Subscription: {
    groups: {
      resolve: (payload, args, {db}) => {
        if (payload.event === Event.ADDED) {
          // do a direct grapher query to get the linked data
          let linkedDoc = db.groups.createQuery({
            $filters: {
              _id: payload.doc._id
            },
            _id: 1,
            name: 1,
            description: 1,
            members: {
              _id: 1,
              name: 1,
              company: 1
            },
            admins: {
              _id: 1,
              name: 1,
              company: 1
            }
          }).fetch();
          if (linkedDoc && linkedDoc.length) {
            // there should be only one record since we filtered on the added doc
            return ({
              doc: linkedDoc[0],
              event: payload.event
            });
          }
          // something went wrong, send back original payload
          return (payload);
        }
        return (payload);
      },
      subscribe(_, args, context) {
        console.log("Calling groups subscription; user = " + context.userId);

        // sanity checks
        if (!context.userId) {
          throw new Meteor.Error("authorization-error", "Action not authorized");
        }

        const observer = context.db.groups.find({
          memberIds: context.userId
        });

        return asyncIterator(observer);
      }
    }
  },
...

It would be nice to figure out what the associated query was in the initial ReactiveQuery subscription, so that we know exactly what date to send back.

But this works for now...

from apollo.

theodorDiaconu avatar theodorDiaconu commented on August 28, 2024

@ujwal-setlur indeed, this is currently a limitation, and even if we do this, grapher could export a functionality that does this essentially, however it's very problematic with links in which storage is on the other side, because you have to watch those documents too! So it kinda sucks, and we have to rely on something like publish-composite but for Apollo.

This would be a good feature request.

from apollo.

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.