tailcall
tailcall copied to clipboard
Improvements for cache implementation
Problem description
In the current cache implementation, if @cache
is added to fields of a type and not to the query where it is being resolved then the values doesn't get cached.
type Query {
posts: [Post] @http(path: "/posts")
}
type Post {
id: Int! @cache(maxAge: 3000)
userId: Int! @cache(maxAge: 4000)
title: String!
body: String!
user: User @http(path: "/users/{{value.userId}}")
}
The above config will not result in any form of caching.
type Query {
posts: [Post] @http(path: "/posts") @cache(maxAge: 3000)
}
type Post {
id: Int!
userId: Int!
title: String!
body: String!
user: User @http(path: "/users/{{value.userId}}")
}
This config, however, will cache the result of posts
query.
Solution One of the ways of fixing this issue is to do the following:
- Add a field in
ServerContext
to hold the values provided by@cache
directive for whichever field it is added to. - While creating the resolver function in
src/blueprint/into_schema.rs
use thefield.of_type.name
to get the type of output and use it to determine what caching rules are applied to the type and the fields of that type and use them to decide what values to fetch and what already exist in the cache.
@tusharmath I want to work on this one
Action required: Issue inactive for 30 days. Status update or closure in 7 days.
Issue closed after 7 days of inactivity.