Error when creating new location document in Sanity Studio
11 replies
Last updated: Jul 11, 2022
L
I'm getting the following error immediately after trying to create a new
Creating new
Any insights as to what's going on (what is
locationdocument in Sanity Studio (v2.30.1).
Unknown document type: * This document has the schema type *, which is not defined as a type in the local content studio schema. Here is the JSON representation of the document: { "_type": "location" }
locationdocuments has worked before (I have many existing
locationdocuments up already).I'm not sure what I changed to cause this error.
Any insights as to what's going on (what is
*referring to?) or how to debug this would be greatly appreciated!
Jul 8, 2022, 10:34 PM
L
I'm importing the
Then utilizing the imports as below (partial snippet):
locationdocument the same as my other documents like this (
locationis at the top):
// Document types ā Page Related import location from './documents/location' import menu from './documents/menu' import menuSpecial from './documents/menu-special' import groupLocation from './documents/group-location' import groupMenu from './documents/group-menu' import groupVenueArea from './documents/group-venue-area' import brand from './documents/brand' import redirect from './documents/redirect' import tag from './documents/tag' import category from './documents/category' import post from './documents/post' import postTag from './documents/post-tag' import event from './documents/event' import partnership from './documents/partnership'
export default createSchema({ // The name of our schema name: 'content', types: schemaTypes.concat([ /* ----------------- */ /* 1: Document types */ // Meta page, generalSettings, promoSettings, headerSettings, footerSettings, seoSettings, navMenu, // Page Related location, menu, menuSpecial, groupLocation, groupMenu, groupVenueArea, brand, redirect, tag, category, post, postTag, event, partnership, ...
Jul 8, 2022, 10:40 PM
L
Here's my entire
schema.jsif that helps
Jul 8, 2022, 10:42 PM
L
I've already tried simplifying the
Other documents (like
locationdocument to a single basic "Title" string field, to see if this error is related to an error in my document schema file, but still the error persists when creating new
locationdocuments.
Other documents (like
postfor blog posts) throw the same error, however most other document types in the project (e.g.
tag) work as expected with no errors upon creation.
Jul 8, 2022, 10:44 PM
That doesn't look like it should be causing any problems. What does the location document schema look like?
Jul 8, 2022, 11:34 PM
L
The
locationdocument type is rather large, so it's broken up into multiple JS files. Here's all the related files:
Jul 9, 2022, 12:23 AM
L
Here's a quick screencast of the error. Interesting (to me) that the JSON changes from
"_type": "*"to
"_type": "location"quickly after.
Jul 9, 2022, 12:32 AM
L
Versions from `package.json`:
"@sanity/base": "^2.30.1", "@sanity/cli": "^2.30.2", "@sanity/color-input": "^2.30.1", "@sanity/components": "^2.14.0", "@sanity/core": "^2.30.2", "@sanity/dashboard": "^2.30.1", "@sanity/default-layout": "^2.30.1", "@sanity/default-login": "^2.30.1", "@sanity/desk-tool": "^2.30.1", "@sanity/production-preview": "^2.29.3", "@sanity/rich-date-input": "^2.0.9", "@sanity/vision": "^2.30.1",
Jul 9, 2022, 12:34 AM
L
We ended up figuring it out:
In the
The new desk structure with
Odd how it worked before, though...
š¤
Thanks for your help
In the
desk/restaurants.jsfile, I had failed to put a
schemaType('location')for the children:
export const restaurantsMenu = S.listItem() .title('Restaurants') .id('restaurants') .child( S.list() .title('Restaurants') .items([ S.listItem() .title('Locations') .child( S.documentTypeList('location').child((documentId) => S.document() .documentId(documentId) .schemaType('location') // ā This was missing .views(standardViews) ) ) .icon(Storefront), ...
.schemaType('location')on the
child()element allows making new documents without error.
Odd how it worked before, though...
š¤
Thanks for your help
user M
Jul 11, 2022, 6:17 PM
AH, I'm so glad you were able to figure it out! I was just preparing to build out a version of this for testing, so your timing is perfect š
!
Jul 11, 2022, 6:20 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.