๐ŸŽค Builder Talk: The Story Behind Lady Gagaโ€™s Digital Experience โ€“ Register now

Issue with loading documents in a studio setup resolved by adding schemaType

8 replies
Last updated: Dec 24, 2021
I ran into an interesting issue. A studio setup that worked fine so far has stopped working.ProductPages are collected by type via the structure builder like so:


S.listItem()
  .title("Product Pages")
  .id("productPages")
  .icon(Icon)
  .child(
    S.documentTypeList("productPage")
      .title("Product Pages")
      .menuItems(S.documentTypeList("productPage").getMenuItems())
      .filter("_type == $type")
      .params({ type: "productPage" })
      .child((documentId) =>
        S.document()
          .documentId(documentId)
          .views(Views({ type: "productPage" }))
      )
)
As mentioned this worked fine so far, but now clicking on one of the items results in an indefinite "Loading document..."

If I reenable collecting all the entries via


S.list()
    .title("Content")
    .items([
      ...S.documentTypeListItems(),
    ])
it again loads the document successfully.

Downgrading / upgrading seems to have not resolved the issue. I also logged out and in again via the CLI.
The dev tools don't provide any useful output besides a structure warning:

Structure warning: document type (
schemaType
) will be required for document nodes in the near future! At:
root > productPages > 82661311-f27a-44f1-88b0-bf756a78a28b"
Dec 24, 2021, 12:54 PM
Hi
user L
- happy holidays! In your custom views, could you try adding a
schemaType
? e.g.
.schemaType('productPage')
Dec 24, 2021, 1:06 PM
This indeed worked:
.child((documentId) =>
        S.document()
          .documentId(documentId)
          .views(Views({ type: "productPage" }))
          .schemaType("productPage")
      )
Dec 24, 2021, 1:09 PM
This indeed worked:
.child((documentId) =>
        S.document()
          .documentId(documentId)
          .views(Views({ type: "productPage" }))
          .schemaType("productPage")
      )
Dec 24, 2021, 1:09 PM
(
views(Views({ type: "productPage" }))
was part of the code earlier as well)
Dec 24, 2021, 1:10 PM
Thank you for the incredibly fast help
user M
! Much appreciated ๐Ÿ™‚
Dec 24, 2021, 1:11 PM
If this is reproducible across different setups, that could mean, that the warning message should possibly be adapted?
At the moment it doesn't suggest anything being broken and feels more like a deprecation warning.
Dec 24, 2021, 1:12 PM
Glad to hear it's working! And I think you're spot on: the warning suggests it shouldn't break (yet). We'll look into fixing this. Thanks for the feedback ๐Ÿ™‚
Dec 24, 2021, 1:14 PM
Thanks again for helping and enjoy the holidays Peter! ๐Ÿ™‚ ๐ŸŽ„
Dec 24, 2021, 1:16 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?

Related answers

Get more help in the community Slack

TopicCategoriesFeaturedRepliesLast Updated
Hey all - whatโ€™s the quickest way to batch delete all documents of a certain type? It looks like the `sanity` cli tool allows...Jan 29, 2021
Best way to convert HTML to a PortableText object?Dec 3, 2020
CLI Error - zsh: command not foundJan 29, 2022
DOMParser is not defined at defaultParseHtmlDec 3, 2020
Next.js and Vercel - Error! No Output Directory named "dist" foundAug 8, 2022
Custom Document Views - Is it Even Possible to Use the Structure Builder?Apr 21, 2022
Hi all! Does anyone have problem on deoplloying on Vercel (Using Next. js as a frontend)? I have two test projects, andonce...Jan 25, 2021
Issue with compiling studio, resolved by nuking node_modules and installing with `sanity install`Aug 21, 2020
How to Disallow Robots on a SubdomainNov 12, 2020
Issue setting value of JSON field with document action in Sanity StudioApr 22, 2020

Related contributions

Turbo Start Sanity
- Template

The battle-tested Sanity template that powers Roboto Studio's websites

Go to Turbo Start Sanity

Schema UI - Next.js Sanity Starter
- Template

A Next.js starter template with Next.js 15, Tailwind CSS, shadcn/ui, and Sanity CMS with Live Editing. Get production-ready React components with matching Sanity schemas and queries. Build dynamic pages faster while keeping full control over customization.

Serge Ovcharenko
Go to Schema UI - Next.js Sanity Starter

The Swaddle
- Made with Sanity

A new brand identity to represent a more mature company, to signify The Swaddleโ€™s evolution from publisher to production house, combined with an easier to navigate platform that can surface multiple content types - drawing readers through The Swaddleโ€™s content offering.

Nightjar
Go to The Swaddle