ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
4.96k stars 722 forks source link

HotChocolate.Caching with queries using DefaultMaxAge will be scoped to private #7055

Closed kiangkuang closed 3 weeks ago

kiangkuang commented 1 month ago

Product

Hot Chocolate

Version

13.8.1

Link to minimal reproduction

https://github.com/kiangkuang/HotChocolateDemo

Steps to reproduce

  1. Clone this project that has been minimally configured like in https://www.youtube.com/watch?v=sk4XD3Zf64k
  2. Run the project and execute the bookWithDefaultCacheControl query, which has no CacheControlAttribute and will use the value from DefaultMaxAge defined in https://github.com/kiangkuang/HotChocolateDemo/blob/1e3239dd7d37ef78ab9cc5cc5fabecd7912cf1be/Program.cs#L9
    query {
        bookWithDefaultCacheControl {
            title
        }
    }

What is expected?

Response with header

  1. Cache-Control: public, max-age=20000 so the behaviour is consistent with the CacheControlAttribute.Scope default value, or
  2. Cache-Control: max-age=20000 since no default scope was defined, or
  3. A way to configure a default scope like DefaultMaxAge

What is actually happening?

Response with header Cache-Control: private, max-age=20000, with no way to change or remove the private scope for queries without CacheControlAttribute and using the DefaultMaxAge.

This makes the option of DefaultMaxAge unusable for projects where we want the default scope to be public.

Relevant log output

No response

Additional context

No response