Nested types in Canonicals


#1

Can a Canonical have nested types, i.e. not a flat structure but fields who are themselves canonicals? e.g.

type Child {
  a: string
  b: string
}
type Parent {
  c: Child
}

#2

Yes, but if you load Parent canonical data (even if it contains data for Child), only the transforms for Parent will be called. So if you would like to create both ParentEntity and ChildEntity entity types as a result of loading a Parent canonical file, you would need to have two different canonical transform types, e.g. TransformParentToParentEntity and TransformParentToChildEntity.


#3

By the way, here is an example of how this canonical data would be represented in JSON and CSV format:

JSON:

[
  {
    c: {
      a: "ONE",
      b: "TWO"
    }
  },
  {
    c: {
      a: "THREE",
      b: "FOUR"
    }
  }
]

CSV:

c.a,c.b
ONE,TWO
THREE,FOUR

Type references in `make` call in jasmine tests