graphql-platform icon indicating copy to clipboard operation
graphql-platform copied to clipboard

Output Caching support?

Open ziaulhasanhamim opened this issue 1 year ago • 5 comments

Is your feature request related to a problem?

With .Net 7 ASP.NET Core adds support for output caching for rest API in an exquisite way. I think there is a need for caching in hot chocolate too.

 [UsePaging]
 public IEnumerable<User> GetUsers([Service] IUserRespository repository) // cache it?
     => repository.GetUsers();

Caching is very useful for auto paging and filters with ef core queryable where you don't have control over what client going to ask and what you need to return because that's handled in the hot chocolate framework context.

The solution you'd like

Implement caching for queryable and other DB providers maybe

Product

Hot Chocolate

ziaulhasanhamim avatar Aug 03 '22 06:08 ziaulhasanhamim

@tobias-tengler this is a duplicate of the cache control issue or? can you link it and close this one?

michaelstaib avatar Aug 03 '22 18:08 michaelstaib

I mean cache control is only about the headers but since we are talking about output caching here we could apply the same rules and cache the response.

michaelstaib avatar Aug 03 '22 18:08 michaelstaib

I thought so going by the title, but I think the issue is more about resolver level caching.

Anyways, here is the issue talking about the caching of query results: #2089

I also submitted a PR implementing this a while ago, you can take a look at some basic examples in the description of the PR: #4540

For more information on how it's supposed to work (besides the code), you can checkout this: https://www.apollographql.com/docs/apollo-server/performance/caching/

tobias-tengler avatar Aug 03 '22 18:08 tobias-tengler

Like output caching comes with comes with a lot more features. Like you can add tags to specific cache and clear cache by tags name. And as you said it's not about the headers it's about the application configuration for cache

ziaulhasanhamim avatar Aug 03 '22 18:08 ziaulhasanhamim

@michaelstaib Maybe you can also take a look at the PR once you have time, so we can get it in: #4540

tobias-tengler avatar Aug 03 '22 18:08 tobias-tengler

@tobias-tengler this is a duplicate of the cache control issue or? can you link it and close this one?

@michaelstaib The duplicate label here is incorrect. Cache-Control issue discussed in https://github.com/ChilliCream/hotchocolate/pull/4540 is very different from this feature request. It would be very nice to be able to cache output response and, dynamically invalidate it based on certain mutations.

cheema-corellian avatar Sep 08 '22 21:09 cheema-corellian

Yeah but not convinced of output cacheing here... its more batching/dataloader semantics... In general the issue is not precise enough. Its juts throwing an api after something :) I am going to close this one.

We are at the moment working on integrating the Data APIs with DataLoader and batching.

michaelstaib avatar Sep 08 '22 22:09 michaelstaib

In general the issue is not precise enough. Its juts throwing an api after something :)

Yeah because I'm a bit new to Hot Chocolate and not much familiar with the codebase. So it's more like a feature request than a API proposal.

ziaulhasanhamim avatar Sep 09 '22 02:09 ziaulhasanhamim