cult-of-coders / grapher

Grapher: Meteor Collection Joins + Reactive GraphQL like queries
https://atmospherejs.com/cultofcoders/grapher
MIT License
275 stars 53 forks source link

Subscription reactivity issue for many type links #481

Closed gabrielcazacu96 closed 7 months ago

gabrielcazacu96 commented 8 months ago

Issue

Subscription query result does not get updated when a new link is added.

Example

  1. Initial data
    Groups:
    [{ _id: 'groupId1'}, {_id: 'groupId2'}]
    Authors:
    [{_id: 'authorId1', groupIds: ['groupdId1']}, {_id: 'authorId2', groupIds: ['groupdId2']}]
  2. Query
    const query = createQuery({
    groups: {
        authors: {
            groupIds: 1,
        }
    }
    });
  3. If I add groupId1 to the groupIds of authorId2, the query result does not update.
  4. Expected subscription query result
    [{ 
    _id: 'groupId1',
    authors: [{_id: 'authorId1', groupIds: ['groupdId1']}, {_id: 'authorId2', groupIds: ['groupdId1', 'groupdId2']}]
    },
    {
    _id: 'groupId2',
    authors: [{_id: 'authorId2', groupIds: ['groupdId2']}]
    }]
  5. Actual subscription query result never changes
    [{ 
    _id: 'groupId1',
    authors: [{_id: 'authorId1', groupIds: ['groupdId1']}]
    },
    {
    _id: 'groupId2',
    authors: [{_id: 'authorId2', groupIds: ['groupdId2']}]
    }]

    Additional info

    • This seems to happen only for many type links
    • Issue seems to be related to the meteor-publish-composite package and how the cursor events are triggered.
    • Issue happens only if the linked object is already linked to another parent object in the query. In the example, the author is already linked to another group.
gabrielcazacu96 commented 8 months ago

Added demonstration test: https://github.com/cult-of-coders/grapher/pull/482 Only works the first time because after that, the mongodb data is changed.

gabrielcazacu96 commented 8 months ago

Added fix attempt to meteor-publish-composite: https://github.com/Meteor-Community-Packages/meteor-publish-composite/pull/177

gabrielcazacu96 commented 7 months ago

Thanks to #179 this should no longer be an issue once meteor-publish-composite is updated to version v1.8.8

StorytellerCZ commented 7 months ago

@gabrielcazacu96 per your comment this should be fixed in v1.5