Package graphql.cachecontrol
Class CacheControl
- java.lang.Object
-
- graphql.cachecontrol.CacheControl
-
@Deprecated @PublicApi public class CacheControl extends java.lang.Object
Deprecated.Apollo has deprecated their Cache Control specification https://github.com/apollographql/apollo-cache-control This has been deprecated/removed from Apollo some time. Apollo now provides an alternative approach via the @cacheControl directive https://www.apollographql.com/docs/apollo-server/performance/caching/ We are deprecating CacheControl inside graphql-java and this will be deleted in a future release. This class implements the graphql Cache Control specification as outlined in https://github.com/apollographql/apollo-cache-controlTo best use this class you need to pass a CacheControl object to each
DataFetcher
and have them decide on the caching hint values.The easiest way to do this is create a CacheControl object at query start and pass it in as a "context" object via
ExecutionInput.getGraphQLContext()
and then have eachDataFetcher
that wants to make cache control hints use that.Then at the end of the query you would call
addTo(graphql.ExecutionResult)
to record the cache control hints into theExecutionResult
extensions map as per the specification.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CacheControl.Scope
Deprecated.If the scope is set to PRIVATE, this indicates anything under this path should only be cached per-user, unless the value is overridden on a sub path.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CACHE_CONTROL_EXTENSION_KEY
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ExecutionResult
addTo(ExecutionResult executionResult)
Deprecated.- Apollo has deprecated the Cache Control specificationCacheControl
hint(ResultPath path, CacheControl.Scope scope)
Deprecated.- Apollo has deprecated the Cache Control specificationCacheControl
hint(ResultPath path, java.lang.Integer maxAge)
Deprecated.- Apollo has deprecated the Cache Control specificationCacheControl
hint(ResultPath path, java.lang.Integer maxAge, CacheControl.Scope scope)
Deprecated.- Apollo has deprecated the Cache Control specificationCacheControl
hint(DataFetchingEnvironment dataFetchingEnvironment, CacheControl.Scope scope)
Deprecated.- Apollo has deprecated the Cache Control specificationCacheControl
hint(DataFetchingEnvironment dataFetchingEnvironment, java.lang.Integer maxAge)
Deprecated.- Apollo has deprecated the Cache Control specificationCacheControl
hint(DataFetchingEnvironment dataFetchingEnvironment, java.lang.Integer maxAge, CacheControl.Scope scope)
Deprecated.- Apollo has deprecated the Cache Control specificationstatic CacheControl
newCacheControl()
Deprecated.- Apollo has deprecated the Cache Control specification
-
-
-
Field Detail
-
CACHE_CONTROL_EXTENSION_KEY
public static final java.lang.String CACHE_CONTROL_EXTENSION_KEY
Deprecated.- See Also:
- Constant Field Values
-
-
Method Detail
-
hint
@Deprecated public CacheControl hint(ResultPath path, java.lang.Integer maxAge, CacheControl.Scope scope)
Deprecated.- Apollo has deprecated the Cache Control specificationThis creates a cache control hint for the specified path- Parameters:
path
- the path to the field that has the cache control hintmaxAge
- the caching time in secondsscope
- the scope of the cache control hint- Returns:
- this object builder style
-
hint
@Deprecated public CacheControl hint(ResultPath path, CacheControl.Scope scope)
Deprecated.- Apollo has deprecated the Cache Control specificationThis creates a cache control hint for the specified path- Parameters:
path
- the path to the field that has the cache control hintscope
- the scope of the cache control hint- Returns:
- this object builder style
-
hint
@Deprecated public CacheControl hint(ResultPath path, java.lang.Integer maxAge)
Deprecated.- Apollo has deprecated the Cache Control specificationThis creates a cache control hint for the specified path- Parameters:
path
- the path to the field that has the cache control hintmaxAge
- the caching time in seconds- Returns:
- this object builder style
-
hint
@Deprecated public CacheControl hint(DataFetchingEnvironment dataFetchingEnvironment, java.lang.Integer maxAge, CacheControl.Scope scope)
Deprecated.- Apollo has deprecated the Cache Control specificationThis creates a cache control hint for the specified field being fetched- Parameters:
dataFetchingEnvironment
- the path to the field that has the cache control hintmaxAge
- the caching time in secondsscope
- the scope of the cache control hint- Returns:
- this object builder style
-
hint
@Deprecated public CacheControl hint(DataFetchingEnvironment dataFetchingEnvironment, java.lang.Integer maxAge)
Deprecated.- Apollo has deprecated the Cache Control specificationThis creates a cache control hint for the specified field being fetched with a PUBLIC scope- Parameters:
dataFetchingEnvironment
- the path to the field that has the cache control hintmaxAge
- the caching time in seconds- Returns:
- this object builder style
-
hint
@Deprecated public CacheControl hint(DataFetchingEnvironment dataFetchingEnvironment, CacheControl.Scope scope)
Deprecated.- Apollo has deprecated the Cache Control specificationThis creates a cache control hint for the specified field being fetched with a specified scope- Parameters:
dataFetchingEnvironment
- the path to the field that has the cache control hintscope
- the scope of the cache control hint- Returns:
- this object builder style
-
newCacheControl
@Deprecated public static CacheControl newCacheControl()
Deprecated.- Apollo has deprecated the Cache Control specificationCreates a new CacheControl object that can be used to trick caching hints- Returns:
- the new object
-
addTo
@Deprecated public ExecutionResult addTo(ExecutionResult executionResult)
Deprecated.- Apollo has deprecated the Cache Control specificationThis will record the values in the cache control object into the provided execution result object which creates a newExecutionResult
object back out- Parameters:
executionResult
- the starting execution result object- Returns:
- a new execution result with the hints in the extensions map.
-
-