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

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?