cognite-sdk-js icon indicating copy to clipboard operation
cognite-sdk-js copied to clipboard

type generator error

Open gulkaktus opened this issue 2 years ago • 0 comments

The problem

The instances/query endpoint returns a QueryResponse that looks like this:

type QueryResponse = {
   items: Record<string, NodeOrEdge>;
   nextCursor: Record<String, String>
}

This is non-standard and deviates from the service contract design doc, and causes the type generator to fail image (8)

Specifically, it seems like it's expecting that the QueryResponse node is of type arrayTypeNode, but it's considered a typeReferenceNode image

What we've tried so far

  • Create an exception for cases where we have a typeReferenceNode. Intuitively, it seems like it should be possible to extract the items and nextCursor nodes, but we're not sure how. I'm also not sure if this type of nextCursor, which is Record<String, String> is supported.

Our current workaround

  • Generate the types while omitting nextCursor. Add it back manually, then exclude instances from further type generation.

gulkaktus avatar Jan 16 '24 14:01 gulkaktus