Issue with schema type "imageArray" causing deployment error.
8 replies
Last updated: Aug 14, 2020
R
Hi,
Schema problem. I’m trying to do a ‘graphql deploy’ but get a “Encountered anonymous inline object “image” for field/type “imageArray”. I’ve already defined other fields as a global schema type, but I can’t get this image array to work.
Main file
imageArray.js
Can anyone see what I’m doing wrong, please?
Schema problem. I’m trying to do a ‘graphql deploy’ but get a “Encountered anonymous inline object “image” for field/type “imageArray”. I’ve already defined other fields as a global schema type, but I can’t get this image array to work.
Main file
... { title: "Other Images", name: "imageArray", type: "imageArray", }, ...
export default { name: 'imageArray', type: 'array', title: 'More Images', of: [ { type: 'image', options: { metadata: ['lqip', 'palette'] }, fields: [ { title: 'Caption', name: 'caption', type: 'string', options: { isHighlighted: true } }, { title: 'Alternative text', name: 'alt', type: 'string', options: { isHighlighted: true } }, ] }, ] }
Aug 14, 2020, 7:02 AM
T
Is your imageArray added to your schema.js file?
Aug 14, 2020, 7:11 AM
R
Hi User,
Yes,
Yes,
import createSchema from 'part:@sanity/base/schema-creator' import schemaTypes from 'all:part:@sanity/base/schema-type' import siteSettings from './siteSettings' import product from './product' import mainImage from './mainImage' import imageArray from './imageArray' import review from './review' import globalVariables from './globalVariables' export default createSchema({ name: 'mySchema', types: schemaTypes.concat([ siteSettings, product, mainImage, imageArray, review, globalVariables ]) })
Aug 14, 2020, 7:15 AM
R
user T
Any idea, please?Aug 14, 2020, 7:55 AM
T
I think what’s causing a problem is the type “array”. Try this instead:
And in your document you can do a reference, something like this
export default { name: 'mainImage', type: 'image', title: 'Image', fields: [ { ... } ], }
{ name: 'imagesRef', title: 'Images Ref', type: 'array', of: [ { type: 'mainImage' } ] }
Aug 14, 2020, 8:23 AM
T
You can also use a document for your imageArray if you have more fields
Aug 14, 2020, 8:24 AM
T
It should give you something like this
Aug 14, 2020, 8:25 AM
R
Thank you - it looked like the “array” was causing the problem. I’ll try this now
Aug 14, 2020, 8:26 AM
R
user T
Worked like a charm. Sincere thanks for your help! 👍👍Aug 14, 2020, 8:38 AM
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.