Go Behind the Experience to see how Tecovas brings the West to life with Sanity 🤠 July 18th

Issue with importing and defining schemas in Sanity.io

10 replies
Last updated: May 22, 2021
Hey guysI have two schemas marketing and adBanner in simple terms marketing is an array of adBanners. I have defined the schemas as bellow.

_export_ default {

title: "Marketing",

name: "marketing",

type: "array",

of: [{ type: "adBanner" }],


_export_ default {

title: "Ad Banner",

name: "adBanner",

type: "document",

fields: [


title: "Promo Banner type",

name: "promoType",

type: "string",



title: "Promo Heading",

name: "promoHeading",

type: "string",



title: "Promo Text",

name: "promoText",

type: "array",

of: [{ type: "block" }],



title: "Affiliate marketing link",

name: "promoLink",

type: "url",



title: "Promo product image",

name: "promoImage",

type: "image",




but when i compile and run i can only see adBanner but not marketing section. When i debug it says

Unknown type: adBanner. Valid types are: marketing, array, block, boolean, datetime, date, document, email, file, geopoint, image, number, object, reference, slug, string, telephone, text and url

Any explanation/fixes for this.
May 22, 2021, 8:38 AM
user V
- are both imported to schema?
May 22, 2021, 10:27 AM
Yes Luke both imported
May 22, 2021, 11:02 AM
Weird - that message usually indicates it hasn’t been imported
May 22, 2021, 11:15 AM
Want to share your schema file?
May 22, 2021, 11:15 AM
import createSchema from "part:@sanity/base/schema-creator";

// Then import schema types from any plugins that might expose them

import schemaTypes from "all:part:@sanity/base/schema-type";

import story from "./stroy";

import author from "./author";

import chapter from "./chapter";

import artworks from "./artworks";

import adBanner from "./adBanner";

import marketing from "./marketing";

// Then we give our schema to the builder and provide the result to Sanity

_export_ default createSchema({

// We name our schema

name: "default",

// Then proceed to concatenate our document type

// to the ones provided by any plugins that are installed

types: schemaTypes.concat([

/* Your types here! */








May 22, 2021, 11:18 AM
for some reason simple schema which includes type array does not work its weird
_export_ default {

title: "Marketing",

name: "marketing",

type: "array",

of: [{ type: "string" }],

got this straight from the docs still not working
May 22, 2021, 11:21 AM
hm yeh, I think that might need to be an object with an array inside it
May 22, 2021, 11:22 AM
i think i tried that too but not sure about the syntax entirely can you provide me an example using the above schema if no trouble?
May 22, 2021, 11:24 AM
Thanks for the help figured it out its due to nested arrays so wrapping it out in a object works. I didnt realise both schema types were arrays.cheers
May 22, 2021, 1:21 PM
ah great news Shawin, sorry I wasn't around to debug the schema, but glad you figured it out
May 22, 2021, 1:22 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?