Skip to content

Problem with @Subscription(): stale data is returned for the lifetime of the subscription #36

Description

@andreialecu

It appears that when GQL Subscriptions are used, the data returned by dataloaders will remain stale for the duration of the subscription.

I believe this happens because the context is the same for the lifetime of the subscription, so once data gets initially cached, it keeps returning the same initial result for DataLoader-resolved fields.

Manually clearing the cache by injecting the Loader and calling loader.clearAll() prior to returning from the @Subscription() method seems to work. This can be tricky to do depending on how many loaders are used and where they are defined, and is prone to bugs by forgetting to clear something.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions