Why does payload generate:types not include collection arrays?

default discord avatar
7 months ago

We are getting a list of news items from payload using the rest API which returns the below JSON.

When we use the keyword

payload generate:types

it doesn't include a root type for the docs array.

We've managed to get around it by providing a news root type as shown below. Is there any way to not have to do this? We have a lot of collections of data we need to fetch.

News root type we have created

export interface NewsRoot {
  docs: News[]

News type generated by payload

export interface News {
  id: string;
  newsTitle: string;
  newsSubtitle?: string;
  tags?: string[] | Tag[];
  publishDate: string;
  newsBackgroundImage?: string | Media;
  newsDescription: {
    [k: string]: unknown;
  createdAt: string;
  updatedAt: string;

News Response JSON

         "newsTitle":"Example News Post",
         "newsSubtitle":"Example subtitle ",
               "tagName":"Tag 1",
               "tagName":"Tag 2",
                     "text":"Example news post"
  • discord user avatar
    Payload Team
    6 months ago

    Hi @MRL - we will definitely include this in our future updates to


    , I've made a note on a related github discussion that you can find here

  • default discord avatar
    6 months ago

    Thanks @jesschow. I will keep an eye out for a future update 🙂

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.