Skip to main content
Solved

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


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

Best answer by Tom Thorsen

Great, thanks David, I will try it out

View original

Anita Hæhre
Seasoned Practitioner
Forum|alt.badge.img+1
  • Head of Academy and Community
  • March 16, 2022

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


David Liu
Seasoned Practitioner
  • Seasoned Practitioner
  • March 16, 2022

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


David Liu
Seasoned Practitioner
  • Seasoned Practitioner
  • March 17, 2022

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!


David Liu
Seasoned Practitioner
  • Seasoned Practitioner
  • March 18, 2022

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


Great, thanks David, I will try it out


Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings