🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Discussion of hoisting issue when deploying GraphQL API with multidimensional repeating input

11 replies
Last updated: Aug 23, 2021
Hey, I’ve got a hoisting issue when deploying a GraphQL API, around a multidimensional repeating input. The error is
Error: Encountered anonymous inline object “column” for field/type “imageGridColumn”. 

It’s complaining about this file, and I’m not sure how I can extract it further.
imageSet
is already it’s own extracted schema:
export default {
  title: "Columns",
  name: "imageGridColumn",
  type: "array",
  of: [
    {
      name: "column",
      title: "Column",
      type: "imageSet",
    },
  ],
};
Aug 20, 2021, 7:39 PM
Hi, sorry to be re-posting, but I’d really appreciate any help anyone can give here. I think I must be missing something obvious!
Aug 23, 2021, 10:19 AM
I’ve also tried popping the array inside an object like so:
export default {
  title: "Columns",
  name: "imageGridColumn",
  type: "object",
  fields: [
    {
      type: "array",
      name: "imageSetColumns",
      title: "Image Set Columns",
      of: [
        {
          name: "imageSetColumn",
          title: "Column",
          type: "imageSet",
        },
      ],
    },
  ],
};
But I get the same error
Aug 23, 2021, 10:28 AM
Sorry to be a mentions pest, but
user M
/
user A
- are either of you able to shed some light on this?
Aug 23, 2021, 4:19 PM
(Feel free to tell me to wait my turn, I’ve just seen plenty of people asking questions and getting answers since this, so I thought it might’ve been lost)
Aug 23, 2021, 4:20 PM
Hi Jodi. We’re here to help so I invite you to reach out to us! This works for me when I create imageSet as an object containing a string field. What does your
imageSet
schema look like?
Aug 23, 2021, 5:53 PM
Good question!

// imageSet.ts

export default {
  type: "object",
  title: "Image Set",
  name: "imageSet",
  fields: [
    {
      type: "imageSetData",
      name: "imageSetData",
      title: "Image Set Data",
    },
    {
      type: "gallery",
      title: "Images",
      name: "images",
    },
  ],
};
Which begs the question:

// imageSetData.ts

export default {
  type: "object",
  name: "imageSetData",
  title: "Image Set Data",
  fields: [
    {
      type: "string",
      title: "Title",
      name: "title",
      description: "Optional title for the image set.",
    },
  ],
};
and


// gallery.ts

export default {
  type: "array",
  title: "Gallery",
  name: "gallery",
  of: [
    {
      type: "image",
      title: "Image",
      name: "image",
    },
  ],
  options: {
    layout: "grid",
  },
};
Aug 23, 2021, 6:03 PM
Good question!

// imageSet.ts

export default {
  type: "object",
  title: "Image Set",
  name: "imageSet",
  fields: [
    {
      type: "imageSetData",
      name: "imageSetData",
      title: "Image Set Data",
    },
    {
      type: "gallery",
      title: "Images",
      name: "images",
    },
  ],
};
Which begs the question:

// imageSetData.ts

export default {
  type: "object",
  name: "imageSetData",
  title: "Image Set Data",
  fields: [
    {
      type: "string",
      title: "Title",
      name: "title",
      description: "Optional title for the image set.",
    },
  ],
};
and


// gallery.ts

export default {
  type: "array",
  title: "Gallery",
  name: "gallery",
  of: [
    {
      type: "image",
      title: "Image",
      name: "image",
    },
  ],
  options: {
    layout: "grid",
  },
};
Aug 23, 2021, 6:03 PM
Thanks for the added detail. I’m able to deploy this code without issue. I’ll try to dig into it a bit more.
Aug 23, 2021, 6:29 PM
Thanks for the added detail. I’m able to deploy this code without issue. I’ll try to dig into it a bit more.
Aug 23, 2021, 6:29 PM
user A
Thanks so much for taking a look, I really appreciate it. I just tried rewriting this from scratch using different type names, and it suddenly works. I think there was a namespace clash somewhere else. I’m not quite sure, I can’t make sense of it even carefully looking through my git history. But if it works, it works! Thanks for prompting me to re-examine things.
Aug 23, 2021, 6:35 PM
Great! Happy to hear you got it working.
Aug 23, 2021, 7:31 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?