The Akwatype types allows to declare that a field corresponds to an object list.
For example a Company with a list of activities :
type Company{ name:String activity:[Activity] }
type Activity { code:String label:String }
A Json corresponding to this description could be :
{
"name": "ACME",
"activity": [
{
"code": "A1",
"label": "Label 1"
},
{
"code": "A2",
"label": "Label 2"
},
{
"code": "A3",
"label": "Label 3"
}
]
}
We might need to build a facade where the activities are limited to three and where each of them is in a dedicated field (It's not great, but we have encountered this type of configuration when exchanging data with old legacy systems).
To realize this type of description we can use the baseOn property which allows to say that an additional field is based on an existing field of the type on which the facade is defined.
facade CompanyDTO on Company{ additionalFields { activity1:Activity{basedOn:activity} activity2:Activity{basedOn:activity} activity3:Activity{basedOn:activity} } name }
If several fields are based on the same list field Akwatype considers that the first one is based on the first element of the list, the second one on the second element of the list, etc ...
It is of course always possible to associate facades on additional fields to apply a transformation on each of them.
facade CompanyDTO2 on Company{ additionalFields { activity1:Activity{basedOn:activity} activity2:Activity{basedOn:activity} activity3:Activity{basedOn:activity} } name with (activity1) { code1:code, label1:label } with (activity2) { code2:code, label2:label } with (activity3) { code3:code, label3:label } }