Discussion of hoisting issue when deploying GraphQL API with multidimensional repeating input
11 replies
Last updated: Aug 23, 2021
J
Hey, I’ve got a hoisting issue when deploying a GraphQL API, around a multidimensional repeating input. The error is
It’s complaining about this file, and I’m not sure how I can extract it further.
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.
imageSetis 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
J
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
J
I’ve also tried popping the array inside an object like so:
But I get the same error
export default { title: "Columns", name: "imageGridColumn", type: "object", fields: [ { type: "array", name: "imageSetColumns", title: "Image Set Columns", of: [ { name: "imageSetColumn", title: "Column", type: "imageSet", }, ], }, ], };
Aug 23, 2021, 10:28 AM
J
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
J
(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
imageSetschema look like?
Aug 23, 2021, 5:53 PM
J
Good question!
Which begs the question:
and
// 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", }, ], };
// 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.", }, ], };
// 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
J
Good question!
Which begs the question:
and
// 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", }, ], };
// 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.", }, ], };
// 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
J
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
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.