close

Filter

loading table of contents...

Headless Server Developer Manual / Version 2301

Table Of Contents

4.11 Using Time Dependent Visibility

The time at which a published content should be visible to the customer can be controlled by validity or visibility. For more information see Section 4.6.14, “Time Dependent Visibility” in Studio User Manual.

To enable time dependent visibility, you have to pass a request header with the view date to the Headless Server. Note that this is only possible in preview mode.

The view date request header is passed as:

  • Header Name: X-Preview-Date
  • Value: Date object in HTTP Date Header standard format, see RFC 7231 for specification

The graphql invocation utilizes PreviewDateContextParameter to forward the view date delivered by the header or, if not available, the current date as a fallback value to the GraphQLContext. The view date can be retrieved via the DataFetchingEnvironment in a data fetcher.

import static com.coremedia.caas.headless_server.plugin_support.PluginSupport.CONTEXT_PARAMETER_NAME_PREVIEW_DATE;
ZonedDateTime viewDate = dataFetchingEnvironment.getGraphQlContext().get(CONTEXT_PARAMETER_NAME_PREVIEW_DATE);

The validity check of content items is performed in the ValidityDateFilterPredicate which is configured in CaasConfig.

The visibility of content items is checked in the PageGridAdapter.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.