Solved

Template: Numeric time series data points typed as DatapointString in GraphQL query result

  • 16 March 2022
  • 5 replies
  • 85 views

Hi, 

I am trying to use templates to model domain specific connections between assets and time series in CDF, and I have come across an issue that I would like some feedback on.

If I have the following schema type:

type StringOrNumber @template {
Asset: Asset
NumericTS: TimeSeries
}

and do the following query:

query StringOrNumber {
stringOrNumberQuery {
items {
NumericTS {
__typename
isString
datapoints(limit: 1) {
__typename
timestamp
value
}
}
}
}
}

then the datapoint output __typename has the value “DatapointString” even though the timeseries is not a string timeseries:

{
"data": {
"stringOrNumberQuery": {
"items": [
{
"NumericTS": {
"__typename": "TimeSeries",
"isString": false,
"datapoints": [
{
"__typename": "DatapointString",
"timestamp": 1634534671570,
"value": 14.3
}
]
}
}
]
}
}
}

The values appear correctly in the query output, so I first noticed the problem when trying to use Strawberry Shake to auto-generate C# types from my query. It uses the __typename value to determine which class to instantiate when deserializing the results into its auto-generated classes - consequently I can not get the data values out since Strawberry Shake instantiates a class that expects “stringValue” in the result if the __typename equals “DatapointString”. 

I can work around it by hand coding my C# classes, but it seems either my understanding or the template implementation is incorrect. 

 

Best Regards,

Tom

icon

Best answer by Tom Thorsen 18 March 2022, 09:51

View original

5 replies

Userlevel 6
Badge

Hi @Tom Thorsen thanks for sharing! You should expect an answer a bit later today:) 

Userlevel 4

Hi Tom,

Thank you for the bug report, we are trying to resolve this bug right now, in the meantime, can you try to cast locally in your code via the workaround? We will update this thread as this gets resolved.

Thanks,

David

Userlevel 4

Update: We have cornered in on a fix that should be rolled out in the coming days, will update the thread once released, thank you for being patient with us!

Userlevel 4

Update: The fix has been deployed 🚀 no more workaround is needed :)

Great, thanks David, I will try it out

Reply