graphql / graphql/dataloader

[REQUEST] Option to not cache errors

Open
#258 0 comments 4 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
13.4k
Forks
518
Avg merge
2d 4h
Merged PRs (30d)
2

Description

## What problem are you trying to solve?
We have cases where we are using a dataloader on the server that utilizes server credentials to cache data that is used to resolve user requests (but not directly accessible to users). We refresh this cache everytime our server credentials are renewed (8 hrs). However, if we end up receiving a network error in those 8 hours, we cache that error as the response for a load.

## Describe the solution you'd like
An option to not cache errors returned in the batch load return array. Or a comparison function that can evaluate whether to cache or not. (eg instanceof checks for certain error types)

## Describe alternatives you've considered
Add additional code at all .load sites to clear the cache of these error values. This is onerous and prone to error
Monkeypatching the dataloader load function to clear the cache when an error is returned.

## Additional context
This seems like it would be handy, but I also understand if it is an overspecific feature

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.