ricokahler / sanity-codegen

Generate TypeScript types from your Sanity.io schemas
sanity-codegen-dev.vercel.app
MIT License
270 stars 19 forks source link

Error: Found unsupported source node type "Unknown" in reduceObjectStructures call. #326

Open michelebruno opened 11 months ago

michelebruno commented 11 months ago

Hi,

I've found a little issue with the query type definition. With the following query I get the error Failed to parse queryGetPageById. Error: Found unsupported source node type "Unknown" in reduceObjectStructures call. Please open an issue. and the query is not added to the types file.

export const getPageByIdQuery = codegen('GetPageById', groq`*[_type == 'page' && _id == $id][0] {
  ..., 
  content[] {
    ...,
    _type == "projectList" => {
      ...,
      projects[]-> {
        ...
      }
    }
  },
}`)

I tried some bug fixing, it looks like that the error only occurs when I try to expand an array of references projects[]-> { ... }.

It would work in these cases projects -> { ... }, projects[]-> or projects[] { ... }

michelebruno commented 11 months ago

Update, it's more related to the .... operator. Is there a way to state the object type in the groq query?