Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Error adding array to rich text and GraphQL deployment error

9 replies
Last updated: May 25, 2021
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
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
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
trying to add that to the portable text schema
May 25, 2021, 5:27 PM
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
well this example im just trying to add 'images' which is also an array of 'figure'
May 25, 2021, 5:28 PM
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
If you’re bringing
responsiveImages
into
richText
, then it appears you’d have an array in an array, which is not currently permitted . Could you try making
responsiveImages
an object containing an array instead?
May 25, 2021, 6:41 PM
ahh ok that worked! Thanks! Forgot that rich text is also an array.
May 25, 2021, 7:36 PM
Awesome!
May 25, 2021, 7:36 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?