Headless Server Developer Manual / Version 2310
Table Of Contents
A query root is the primary object necessary to resolve a GraphQL query. The query root for all content queries
is ContentRoot. It is created
as a Spring bean in the CaasConfig
class and provides access to the content repository.
A query root does not obey any interfaces or standards. The GraphQL runtime handles a query root like a POJO using reflection.
At the same time, the Java class ContentRoot
reflects the GraphQL root type in the query
root of the same name. All fields, defined in the GraphQL type correspond to a getter of the same name, for example the
page
query, which corresponds to the getter public getPage(DataFetchingEnvironment environment)
.
The result of the getter method is the so called root object (not identical to the query root) on which the following
resolving process relies.
On top of the reflection based invocation of the getter methods, CoreMedia added the @fetch
directive, which allows to express the data fetching for a property in the GraphQL scheme using the Spring
Expression Language (SpEL). The Spring EL allows a less restrictive approach to use the query root or even to
invoke completely different objects instead of the ContentRoot
, namely most of the adapters,
like the SettingsAdapter
or the NavigationAdapter
.