apollographql / datasource-rest

A caching data source for REST APIs
MIT License
39 stars 20 forks source link

[Feature Request]: Store JSON responses as objects in the cache instead of stringifying them #361

Open starrett67 opened 6 days ago

starrett67 commented 6 days ago

Summary

I would like to request a feature enhancement that allows JSON responses to be stored as objects in the cache, instead of stringifying them.

Problem

Currently, when caching JSON responses, the package stores them as strings. For my use case, I handle large JSON bodies that can exceed 10MB in size. Every time I retrieve a response from the cache, I noticed that the response times were extremely slow for just reading data from an in memory cache. Parsing JSON objects depending on the size can be introducing a pretty significant performance issue that can be avoided.

Proposed Solution

Allow developers to provide an override method that handles storing the response object in cache

starrett67 commented 6 days ago

I just noticed there is a related discussion to this topic: https://github.com/apollographql/datasource-rest/discussions/329