Current API
const graph = createGraph()
const root = graph.data({
source: "flights",
name: "root"
})
const child = graph.data({
source: "root",
name: "child",
transform: [
{
type: "filter",
expr: "recipient_party = 'D'"
}
]
})
const grandchild = graph.data({
source: "child",
name: "grandchild",
transform: [
{
type: "aggregate",
fields: ["*", "amount"],
ops: ["average", "average"],
groupby: "recipient_party"
}
]
})
Proposed API 1
const graph = createGraph()
const root = graph.createRoot({
source: "flights",
name: "root"
})
const child = root.createChild({
name: "child",
transform: [
{
type: "filter",
expr: "recipient_party = 'D'"
}
]
})
const grandchild = child.createChild({
name: "grandchild",
transform: [
{
type: "aggregate",
fields: ["*", "amount"],
ops: ["average", "average"],
groupby: "recipient_party"
}
]
})
Proposed API 2
const graph = createGraph()
const root = graph.createRoot({
source: "flights",
name: "root"
})
const childNode = createNode({
name: "child",
transform: [
{
type: "filter",
expr: "recipient_party = 'D'"
}
]
})
const grandchildNode = createNode({
name: "grandchild",
transform: [
{
type: "aggregate",
fields: ["*", "amount"],
ops: ["average", "average"],
groupby: "recipient_party"
}
]
})
const child = root.pushChild(childNode)
const grandchild = child.pushChild(grandchildNode)
The two API proposals seem compatible as well.
Graph State is currently represented as:
const state = {
root: {
source: "flights",
name: "root"
},
child: {
source: "root",
name: "child",
transform: [
{
type: "filter",
expr: "recipient_party = 'D'"
}
]
},
grandchild: {
source: "child",
name: "grandchild",
transform: [
{
type: "aggregate",
fields: ["*", "amount"],
ops: ["average", "average"],
groupby: "recipient_party"
}
]
}
}
In the latter two proposals it would be represented as:
const state = {
root: {
source: "flights",
name: "root",
children: [
child
]
}
}
const childState = {
source: root,
name: "child",
transform: [
{
type: "filter",
expr: "recipient_party = 'D'"
}
],
children: [
grandchild
]
}
const grandchildState = {
source: child,
name: "grandchild",
transform: [
{
type: "aggregate",
fields: ["*", "amount"],
ops: ["average", "average"],
groupby: "recipient_party"
}
],
children: []
}