我的数据库中有以下复杂/嵌套的metrics
字典,我想通过GraphQL Session
类型将其传递给前端。但是,由于GraphQL不提供Dictionary
类型,因此我不确定如何对该字典建模。
// structure of metrics
metrics {
[task: string]: {
[balanceKey: string]: {
metricName1: float,
metricName2: float,
}
}
}
type Session {
metrics: ???
}
恐怕我唯一的选择是创建以下嵌套的对象结构。这是显示数据的唯一方法,还是有人想起更好的建议或结构。非常感谢您的帮助:)
type Session {
tasks: [Task]
}
type Tasks {
name: String
balanceKeys: [BalanceKey]
}
type BalanceKey {
name: String
metrics: [Metric]
}
type Metric {
name: String
value: Float
}