@source directive
The @source directive remaps a field to another field by path (a relative path from the current position).
Arguments
path- The JSON relative path for field value search. This argument support the specifications of JsonPath. For more information about JsonPath, refer to https://github.com/json-path/JsonPath.
singleResult-
A flag that, if set to
true, causes the directive to convert any single-element array into an object (that is, to remove [ ] in the resulting JSON if the array contains only one item).
Examples
- Content
-
{ "Page": { "Article": { "body": { "content": "test content", "image": "image" }, "header": "content header" } } } - Model
-
type Page { articleBody : String @source(path: "$.Article.body.content") } - Query
-
{ getContent() { Page: { articleBody } } } - Result
-
{ "data": { "Page": { "articleBody": "test content" } } }