close

Filter

loading table of contents...

Headless Server Developer Manual / Version 2406.1

Table Of Contents

4.2.3.3 ModelMapper

Implementations of ModelMapper are used as an additional conversion layer to convert the types delivered by a DataFetcher into a type, which ideally can be processed directly by the GraphQL runtime. Technically a ModelMapper is a Java Function with the signature Function<T, Optional<R>>.

All ModelMapper instances are created as regular Spring beans which are then consumed and invoked by the CompositeModelMapper. During runtime, the CompositeModelMapper tries to find an appropriate ModelMapper for a resolved property and applies it for type conversion. Headless Server features two ModelMapper implementations out of the box, the richTextModelMapper and the dateModelMapper. Both are created in CaasConfig.

The FilteringModelMapper is the so called rootModelMapper. As the name rootModelMapper implies, FilteringModelMapper acts as the first ModelMapper in the invocation chain of ModelMapper instances. FilteringModelMapper has two tasks. It invokes a list of Predicates to filter the resolved content, then it delegates the filter result to the CompositeModelMapper which in turn invokes the type conversion with a suitable ModelMapper.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

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