👋 Next.js Conf 2024: Come build, party, run, and connect with us! See all events

Issue creating a document in Sanity Studio due to invalid schema

10 replies
Last updated: Feb 27, 2023
Hi! When I create a document in sanity studio, I met some issue.
This document has the schema type *, which is not defined as a type in the local content studio schema.
Let me know any hint please.
Thanks for your time.
🎉
Feb 24, 2023, 1:51 AM
Can you paste in your current schema?
Feb 24, 2023, 12:36 PM
sure
Feb 24, 2023, 3:17 PM
import {DocumentIcon} from '@sanity/icons';

import {validateSlug} from '../../utils/validateSlug';


export default {

name: 'page',

title: 'Page',

type: 'document',

icon: DocumentIcon,

groups: [

{

name: 'theme',

title: 'Theme',

},

{

default: true,

name: 'editorial',

title: 'Editorial',

},

{

name: 'seo',

title: 'SEO',

},

],

fields: [

// Title

{

name: 'title',

title: 'Title',

type: 'string',

validation: (_Rule_) _=>_
_Rule_.required(),

},

// Slug

{

name: 'slug',

type: 'slug',

options: {source: 'title'},

validation: validateSlug,

},

// Color theme

{

name: 'colorTheme',

title: 'Color theme',

type: 'reference',

to: [{type: 'colorTheme'}],

group: 'theme',

},

// Show hero

{

name: 'showHero',

title: 'Show hero',

type: 'boolean',

description: 'If disabled, page title will be displayed instead',

initialValue: false,

group: 'editorial',

},

// Hero

{

name: 'hero',

title: 'Hero',

type: 'hero.page',

hidden: ({_document_}) _=>_ !_document_?.showHero,

group: 'editorial',

},

// Body

{

name: 'body',

title: 'Body',

type: 'body',

group: 'editorial',

},

// SEO

{

name: 'seo',

title: 'SEO',

type: 'seo.page',

group: 'seo',

},

],

preview: {

select: {

active: 'active',

seoImage: 'seo.image',

title: 'title',

},

prepare(_selection_) {

_const_ {seoImage, title} = _selection_;


return {

media: seoImage,

title,

};

},

},

};
Feb 24, 2023, 3:18 PM
Did you get to desk tool without problems? And when you encounter the issue only when you click the New button to create a new
page
document?
Feb 25, 2023, 12:26 PM
It looks to me that the schema is invalid.
Feb 25, 2023, 12:26 PM
Let me know in detail.
Feb 26, 2023, 10:37 AM
I mean, I tried this and I’m probably missing a few files or I’m just not sure about using
seo.image
for example whether that’s valid.
Feb 26, 2023, 1:47 PM
I think you have the schema there for
seo
correct? can you send it and the others?
Feb 26, 2023, 1:47 PM
I don't think it is issue. Would you like to try without that? Otherwise it is related to saved documents? There are 2 page documents already.
Feb 26, 2023, 11:24 PM
unfortunately, I can’t replicate your setup to the best of my abilities. with the schema you provided, I can’t run Sanity studio because there were errors
Feb 27, 2023, 1:15 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?