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

Issue with schema update not reflecting on front end in GatsbyJS

10 replies
Last updated: Oct 14, 2021
Hi all, I am building a main navigation and wanted to have the option to have different styled links. I have updated the schema with a type of "string" , named "style" . When I inspect the json in the admin, I can see that field exist, but when looking at the data on the front end, it does not show up? I am using GatsbyJS for the frontend
Oct 14, 2021, 4:49 PM
export default {
title: "Call to action",
name: "cta",
type: "object",
fieldsets: [
{
title: "Link",
name: "link",
description: "Only the first value of these will be used",
},
],
fields: [
{
title: "Title",
name: "title",
type: "string",
},
{
title: "Landing page",
name: "landingPageRoute",
type: "reference",
fieldset: "link",
to: [{ type: "route" }],
},
{
title: "Path",
name: "route",
fieldset: "link",
description: "Example: /blog",
type: "string",
},
{
title: "External link",
name: "link",
type: "string",
description: "Example:
https://website.com ", fieldset: "link",
},
{
title: "Style",
name: "style",
description: "What style of link ",
type: "string",
options: {
layout: "dropdown",
list: ["button", "link"],
},
},
{
title: "Kind",
name: "kind",
type: "string",
options: {
layout: "radio",
list: ["button", "link"],
},
},
],
preview: {
select: {
title: "title",
landingPage: "landingPageRoute.slug.current",
route: "route",
link: "link",
},
prepare({ title, landingPage, route, link }) {

_let_ subtitle = "Not set";
if (landingPage) {
subtitle = `Route: /${landingPage}`;
}
if (route) {
subtitle = `Route: ${route}`;
}
if (link) {
subtitle = `External: ${link}`;
}

_return_ {
title,
subtitle,
};
},
},
};
Oct 14, 2021, 4:49 PM
also, tried deploying graphql , but still no luck
Oct 14, 2021, 4:54 PM
Hey Kyle, I know you mentioned deploying graphql, but does that mean you redeployed after you made the changes to your schema?
Oct 14, 2021, 6:20 PM
first , I had made the changes to my local, verified in the Studio the schema was update, but was not updated on the front end. then deployed graphql ,which them prompted me with the scheme changes and was successful
Oct 14, 2021, 6:24 PM
it weird, cause I have made some small changes to this CTA schema and it did update in the past, just the "style" one is not coming though?
Oct 14, 2021, 6:24 PM
Got it. And what does your query look like on your frontend?
Oct 14, 2021, 6:25 PM
brb, got to jump on a call
Oct 14, 2021, 6:30 PM
back, annnnd I didn't realize the Nav items query was broken out into a fragment, added "style" and all is good, Thanks!
Oct 14, 2021, 7:15 PM
Awesome! Glad you got it sorted out!
Oct 14, 2021, 7:26 PM
Awesome! Glad you got it sorted out!
Oct 14, 2021, 7:26 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?