Error adding array to rich text and GraphQL deployment error
9 replies
Last updated: May 25, 2021
P
has anyone gotten this error when trying to add an array to rich text? It crashes the whole studio
TypeError: (value || []).some is not a function
at ArrayInput.render (/static/js/app.bundle.js:334325:44)
at finishClassComponent (/static/js/vendor.bundle.js:20318:31)
at updateClassComponent (/static/js/vendor.bundle.js:20268:24)
at beginWork (/static/js/vendor.bundle.js:21778:16)
at HTMLUnknownElement.callCallback (/static/js/vendor.bundle.js:3346:14)
at Object.invokeGuardedCallbackDev (/static/js/vendor.bundle.js:3395:16)
at invokeGuardedCallback (/static/js/vendor.bundle.js:3450:31)
at beginWork$1 (/static/js/vendor.bundle.js:26361:7)
at performUnitOfWork (/static/js/vendor.bundle.js:25312:12)
at workLoopSync (/static/js/vendor.bundle.js:25288:22)May 25, 2021, 3:45 PM
P
and also getting this error after trying updating the studio when I try to deploy graphql 😞
Error: Syntax Error: Expected Name, found [ at ~/web/stoneroad/sanity/node_modules/@sanity/core/lib/actions/graphql/deployApiAction.js:156:31
at Generator.throw (<anonymous>)
at asyncGeneratorStep (~/web/stoneroad/sanity/node_modules/@sanity/core/lib/actions/graphql/deployApiAction.js:7:103)
at _throw (~/web/stoneroad/sanity/node_modules/@sanity/core/lib/actions/graphql/deployApiAction.js:9:291)May 25, 2021, 4:08 PM
P
export default {
name: "responsiveImages",
type: "array",
title: "Responsive Images",
of: [
{
type: "object",
fields: [
{ name: "image", type: "figure" },
{
name: "size",
type: "string",
options: {
list: [
{ title: "Sci-Fi", value: "sci-fi" },
{ title: "Western", value: "western" },
],
layout: "radio",
},
},
],
},
],
};May 25, 2021, 5:27 PM
P
trying to add that to the portable text schema
May 25, 2021, 5:27 PM
P
import { BsFillImageFill, BsImages } from "react-icons/Bs";
export default {
name: "richText",
title: "Rich text",
type: "array",
of: [
{
type: "block",
styles: [
{ title: "Normal", value: "normal" },
{ title: "H1", value: "h1" },
{ title: "H2", value: "h2" },
],
lists: [],
marks: {
decorators: [
{ title: "Strong", value: "strong" },
{ title: "Underline", value: "underline" },
],
},
},
{ type: "figure" },
{ type: "lineBreak" },
{ type: "images" },
],
};May 25, 2021, 5:28 PM
P
well this example im just trying to add 'images' which is also an array of 'figure'
May 25, 2021, 5:28 PM
P
but now the graphql doesn't work in general after updating the studio. do you think you could help with that?
May 25, 2021, 5:29 PM
G
If you’re bringing
responsiveImagesinto
richText, then it appears you’d have an array in an array, which is not currently permitted . Could you try making
responsiveImagesan object containing an array instead?
May 25, 2021, 6:41 PM
P
ahh ok that worked! Thanks! Forgot that rich text is also an array.
May 25, 2021, 7:36 PM
G
Awesome!
May 25, 2021, 7:36 PM
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.