Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
andreialecu opened this issue Jul 18, 2020 · 3 comments

Comments

@andreialecu
Copy link

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.

@andreialecu
Copy link
Author

Related: graphql/graphql-js#894

@andreialecu
Copy link
Author

Until merge of graphql/graphql-js#2485 seems like the only solution is to disable caching on all data loaders via { cache: false }

@dimatill
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants