How to create metrics that takes field with no path needed


#1

Hi!

I was trying to create a metrics to get the field longitude from the type Transformer.
The field has already existed on the type Transformer and thus does not need additional path.
However, it does not work when I do this:

{
“id” : “Longitude_Transformer”,
“name” : “Longitude”,
“srcType” : “Transformer”,
“tsDecl” : {
“data” : “Transformer”,
“treatment” : “RATE”,
“start” : “dateInstalled”,
“value” : “longitude”
},
“description” : “The longitude of transformer”
}

What can I do?


#2

as a trick you can add a field called “self” on the Transformer type:

e.g.

type Transformer {
  ...

  self: [Tranformer] (id,id)

}

and then write the metric as:

{
“id” : “Longitude_Transformer”,
“name” : “Longitude”,
“srcType” : “Transformer”,
“tsDecl” : {
“data” : “self”,
“treatment” : “RATE”,
“start” : “dateInstalled”,
“value” : “longitude”
},
“description” : “The longitude of transformer”
}

There will be no performance penalty to adding the fkey reference