✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Troubleshooting deploying new schemas in Sanity Studio for Next.js app

23 replies
Last updated: Jun 6, 2023
Good afternoon! I currently have sanity studio (v3) setup in my next.js application. How do I go about deploying new schemas so I can use the vision tool properly? I added the schemas and they are showing in the desk view, but I can't query them correctly in the vision desk... I noticed that when I went back to "sanity.io/manage " the studio did not have my recent schema changes, yet the localhost:3000/studio/desk does. What do I need to do to add schemas properly? Thanks!
Jun 5, 2023, 6:37 PM
👋 You’ll have to redeploy your Next app to get any local changes to show up on your site.
Jun 5, 2023, 6:40 PM
Thanks for the help! I have my studio setup at localhost:3000/studio. When I go to that page the studio/desk looks correct and as it should.
Jun 5, 2023, 6:44 PM
But groq query doesn't seem to "query" the new schema fields as expected...
Jun 5, 2023, 6:45 PM
Can you share an example of a document you’ve created that doesn’t show up in in Vision? As well as the query you’re running?
Jun 5, 2023, 7:12 PM
Yes, one moment.
Jun 5, 2023, 7:28 PM
import { defineType, defineField } from "sanity";

export default defineType({
title: "community",
name: "Community",
type: "document",
fields: [
defineField({
name: "resource",
title: "Resource",
type: "string",
}),
defineField({
name: "description",
description: "Enter a short snippet for the resource...",
title: "Description",
type: "string",
}),
defineField({
name: "url",
description: "Enter a redirect url",
title: "Url",
type: "string",
}),
defineField({
name: "type",
title: "Type",
type: "array",
of: [{ type: "reference", to: { type: "resource-type" } }],
}),
],
});
Jun 5, 2023, 7:29 PM
import { defineType, defineField } from "sanity";
Jun 5, 2023, 7:29 PM
import { defineType, defineField } from "sanity";export default defineType({
  title: "community",
  name: "Community",
  type: "document",
  fields: [
    defineField({
      name: "resource",
      title: "Resource",
      type: "string",
    }),
    defineField({
      name: "description",
      description: "Enter a short snippet for the resource...",
      title: "Description",
      type: "string",
    }),
    defineField({
      name: "url",
      description: "Enter a redirect url",
      title: "Url",
      type: "string",
    }),
    defineField({
      name: "type",
      title: "Type",
      type: "array",
      of: [{ type: "reference", to: { type: "resource-type" } }],
    }),
  ],
});
Jun 5, 2023, 7:30 PM
*[_type == 'community']
Jun 5, 2023, 7:30 PM
Did you also create a community document in the Studio?
Jun 5, 2023, 7:33 PM
I did not, I created the schema, added it to the schema types and then it showed up in studio/desk.
Jun 5, 2023, 7:34 PM
If I search by types in the studio/desk, type community shows..
Jun 5, 2023, 7:34 PM
Got it. The backend is schemaless, so you won’t be able to query for that type until an actual document exists in your dataset.
Jun 5, 2023, 7:35 PM
okay. Could you please give me a bit of direction to make sure I create a document in the dataset correctly?
Jun 5, 2023, 7:38 PM
In the same way you create any document in the Studio, you’d open it in the desk and add data to it.
Jun 5, 2023, 7:42 PM
I do already have data in the community.
Jun 5, 2023, 7:45 PM
thank you for your help rd!
Jun 5, 2023, 7:45 PM
Ah weird! I misunderstood then. Did you maybe misspell something when you imported it into your
schema.js
?
Jun 5, 2023, 8:11 PM
import blockContent from "./blockContent";
import category from "./category";
import community from "./community";
import resource from "./resource";
import post from "./post";
import author from "./author";

export const schemaTypes = [
  post,
  author,
  category,
  community,
  blockContent,
  resource,
];
Jun 5, 2023, 8:22 PM
Doesn't look like it. Are there any cli commands I need to run for this to properly update the dataset for my projectId? Ive ran sanity build, sanity deploy...
Jun 5, 2023, 8:24 PM
No, any changes you make in the Studio get written to your dataset in real time, even if it’s a local Studio. Do you have mulltiple datasets? If so, is it possible that your Studio is using one dataset, but Vision is querying a different one?
Jun 5, 2023, 8:26 PM
I have a "Freeride blog" and a "production" dataset.
Jun 5, 2023, 8:27 PM
Thanks again rd. I deleted my sanity project, then created a new project with an empty schema, and once I got everything configured, it worked. Just wanted to let you know I got past our issue. Thanks for the support!
Jun 6, 2023, 12:22 AM

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?