Class 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-control

    To 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 each DataFetcher 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 the ExecutionResult extensions map as per the 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 specification
        This creates a cache control hint for the specified path
        Parameters:
        path - the path to the field that has the cache control hint
        maxAge - the caching time in seconds
        scope - 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 specification
        This creates a cache control hint for the specified path
        Parameters:
        path - the path to the field that has the cache control hint
        scope - 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 specification
        This creates a cache control hint for the specified path
        Parameters:
        path - the path to the field that has the cache control hint
        maxAge - 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 specification
        This creates a cache control hint for the specified field being fetched
        Parameters:
        dataFetchingEnvironment - the path to the field that has the cache control hint
        maxAge - the caching time in seconds
        scope - 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 specification
        This 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 hint
        maxAge - 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 specification
        This 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 hint
        scope - 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 specification
        Creates 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 specification
        This will record the values in the cache control object into the provided execution result object which creates a new ExecutionResult object back out
        Parameters:
        executionResult - the starting execution result object
        Returns:
        a new execution result with the hints in the extensions map.