Skip to content

Queries

mweikard edited this page Nov 5, 2018 · 6 revisions

Queries

Each Processing Definition defines a set of queries that can be executed on the CoreMedia content objects.
See Introduction to GraphQL on how to write your own queries.

Each query must start with a special comment which defines the name, view name and root object type of the query. From this description the GraphQL query type is automatically generated.

#!query name=article view=default type=CMArticleImpl

query ArticleQuery {
  ...
}

Directives

The following custom directives are added to the default GraphQL ones and allow modification of the returned field values based on the evaluation of SpEL expressions.

if

Is evaluated on the current object before the data fetcher for a field is executed and allows replacing the otherwise returned value with null (in case of object types) or a scalar value that is convertible from a string and matches the fields type.

Arguments:

  • test: The SpEL expression.
  • else: Optional value.

Example:

  items @if(test: "getLink('viewtype')?.getString('layout') == 'accordion'") {
    ...
  }

Only includes the items property of the current content object if it has the view type accordion.

filter

Is evaluated on the result of the data fetcher and allows for filtering the returned values.

Arguments:

  • test: The SpEL expression.

Example:

  children @filter(test: "?[!$navigation().hidden]") {
    ...
  }

Removes all children from the navigation that should be hidden.

Clone this wiki locally