Issue with updating schema not reflecting in output, GROQ query error causing duplicate entries.

8 replies
Last updated: Jul 7, 2021
for some reason, when I change schema it is not updating the output. I have even added new fields and can see them in the studio.
Jul 4, 2021, 5:57 PM
Hey
user M
, I have tried that countless times and unfortunately it still seems to be retrieving old data which has been updated several times since. Even upon deleting the fields in the schema and adding in new fields with new names etc still nothing new happens.
Is it possible that the dataset has somehow got cached or similar?
Jul 7, 2021, 12:47 AM
So it turns out the GROQ query was wrong.
The
[0]
was making it return zero results so I have removed but now it is returning an array with 2 entries where the first object is
null
and the second entry the field data as follows:

[
    {
        "titleV2": null
    },
    {
        "titleV2": "Welcome to Sanity"
    }
]
Why is it returning me two entries for the 1 field being queried like so?


*[_type == "homepage"]{
  titleV2
}
Jul 7, 2021, 1:09 AM
Ah, so it would seem that you have two
homepage
documents, since GROQ will return an array of all of the documents that match the
*[_type == "homepage"]
filter.
If you only need to have one of that type, you could delete the one that you don’t need and convert the type to a
singleton so that you don’t end up with a duplicate messing up your queries again.
Jul 7, 2021, 3:49 AM
I only have one homepage schema file in the /schemas folder
Jul 7, 2021, 8:27 AM
there isn't any other files apart from the schema.js file in there
Jul 7, 2021, 8:30 AM
The schema describes the structure of a reusable document form for the Studio, not a single document. You can create many documents using a one schema. It can be confusing when first encountering it, I know. This bit of the docs goes through some key aspects of this.As I mentioned previously, you can make it so that you can’t create more than one document using a schema by converting it into a
singleton (or single edit page) , but that requires you to mess around with your Studio’s structure and add some experimental actions to your document.
Jul 7, 2021, 3:11 PM
ok thanks, will take a look
Jul 7, 2021, 3:29 PM
For sure. Let me know if you’re still having trouble.
Jul 7, 2021, 3:30 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?