Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Objects in array are missing _type and _key #236

Closed
piotrski opened this issue Dec 20, 2021 · 2 comments · May be fixed by #294
Closed

Objects in array are missing _type and _key #236

piotrski opened this issue Dec 20, 2021 · 2 comments · May be fixed by #294

Comments

@piotrski
Copy link

Schema:

{
  name: 'content',
  type: 'array',
  title: 'Content',
  of: [
	{
      type: 'youtube',
    },
    {
      name: 'productSection',
      type: 'productSection',
      title: 'Products',
    }
  ]
}

Data:

content: [
  {
    "_key": "9d0a582dd846"
    "_type": "youtube"
    "url": "..."
  },
  {
    "_key": "c4c84d3114c9"
    "_type": "productSection"
    "products": [...] 1 item "title": "Prodct module"
  }
]

Type:

{
	content: Ref_9GdYNyKK3JQZWeEb | Ref_rxXogl98csCHdj1D
}
type Ref_9GdYNyKK3JQZWeEb = {
      _key: string; // it's missing
      _type: "youtube"; // missing
      url?: string;
      videoLabel?: string;
};

type Ref_rxXogl98csCHdj1D =
  | {
      _key: string; // it's missing
      _type: "productSection" // missing
      products?: Ref_xVWTU39k4Au07eM0[];
      title?: string;
    }[]
  | null;

This might be related to #85
I'm using groq-codegen v1.0.0-alpha.25

@HuyAms
Copy link

HuyAms commented Mar 23, 2022

I face up with the same issue with reference type missing _type and _key. Any walkaround?

@bertwillekens
Copy link

I also need access to the _key property in my models.

@piotrski piotrski closed this as not planned Won't fix, can't repro, duplicate, stale Oct 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants