Documentation Center

@typeSource directive

The @typeSource directive copies all fields from the object in $path into the declared object.

Arguments

path
The JSON global 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.

Examples

Content
{
  "data": {
    "Page": {
      "Article": {
        "body": {
          "content": "test",
          "image": "image",
          "header": "content header"
        }
      }
    }
  }
}
Model
type Page {
  article: Article @typeSource(path: '$.body')
}
type Article {
  header: String
}
Query
{
  getContent() {
    Page: {
      Article: {
        content
        image
        header
      }
    }
  }
}
Result
{
  "data": {
    "Page": {
      "Article": {
        "content": "test",
        "image": "image",
        "header": "content header"
      }
    }
  }
}