Skip to main content

Expression Result

This field available in PRO version only.

The purpose of this field is to create synthetic fields based on data from another fields or to modify the shape of resulted json by writing expressions.

Examples

How to create custom field for current_user based on user display name and email.

query {
current_user {
name: display_name @private
email: user_email @private
user_info: expression_result(expression: "{{name ~ '(email: ' ~ email ~ ')'}}")
}
}

How to transform the shape of resulted json.

Let's pretend the situation we need to get such json in dynamic data:

{
"post": {
"title": "post title",
"content": "post content",
"image": "https://builderius.io/some_image.png"
}
}

Ok, let's write the query:

query {
post: queried_post {
title: post_title
content: post_content
image: featured_image {
file_url
}
}
}

As we can see - the result is not what we want. Even aliases didn't help.

So let's use field expression_result to modify the shape of our json.

query {
post: queried_post {
title: post_title
content: post_content
featured_image @private {
file_url
}
image: expression_result(expression: "{{{featured_image.file_url}}}")
}
}