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

Error after updating Sanity Studio app, resolved by updating "next-sanity" package.

3 replies
Last updated: Sep 29, 2023
Hello Everyone! Recently I updated my Sanity Studio app by running "npm install sanity@latest" and after updating my app from 3.10.3 version to 3.16.7 I am receiving an error alert (attahed screenshot below). The error points to my sanity.utils.ts file and asks for the import, however I am not able to find any new imports from you Sanity docs, so if anybody had the same issue before, please help!
Here is also my sanity.utils.ts file:

    import { createClient, groq } from "next-sanity";
    import {apiVersion, dataset, projectId} from "./env"
    import { Project } from "../types/Project";
    import { client } from "./lib/client";
    import { Page } from "../types/Page";


    export async function getProjects(): Promise<Project[]> {
        const client = createClient({
            projectId,
            dataset,
            apiVersion,
        })

        return client.fetch(
            groq`*[_type == 'project']{
                _id,
                _createdAt,
                name,
                "slug": slug.current,
                "image": image.asset->url,
            }`
        )
    }


    export async function getProject(slug: string): Promise<Project> {
        const client = createClient({
            projectId,
            dataset,
            apiVersion,
        })

        return client.fetch(
            groq`*[_type == 'project' && slug.current == $slug][0]{
                _id,
                _createdAt,
                name,
                "slug": slug.current,
                "images": images[].asset->url,
            }`,
            {slug}
        )
    }


   
    export async function getPages(): Promise<Page[]> { 
        const client = createClient({
            projectId,
            dataset,
            apiVersion,
        })

        return client.fetch(
            groq`*[_type == 'page']{
                _id,
                _createdAt,
                title,
                "slug": slug.current,
            }`
        )
    }

 
    export async function getPage(slug: string): Promise<Page> {
        const client = createClient({
            projectId,
            dataset,
            apiVersion,
        })

        return client.fetch(
            groq`*[_type == 'page' && slug.current == $slug][0]{
                _id,
                _createdAt, 
                "images": images[].asset->url,
                title,
                "slug": slug.current,
            }`,
            {slug}
        )

    }
Sep 29, 2023, 10:50 AM
Hey,
user S
. Have you made sure
next-sanity
is also up-to-date?
Sep 29, 2023, 11:32 AM
Yep, you are right. It fixed my issue. Thaks for help, buddy!
Sep 29, 2023, 12:58 PM
Sure thing mate
Sep 29, 2023, 1:01 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?