Issues with deploying GraphQL after upgrading from V2 to V3 Sanity
6 replies
Last updated: Feb 9, 2023
S
Hello π
Since the upgrade from V2 to V3 sanity, I'm having issues running
I have tried searching through different similar threads, although couldn't figure out where the issue is.
Since the upgrade from V2 to V3 sanity, I'm having issues running
sanity graphql deploy,
production: Could not resolve source `production`: - An error occurred while resolving `tools` from production: Cannot read properties of undefined (reading 'PRODUCTION'
Feb 4, 2023, 12:39 AM
S
sanity.cli.js
// sanity.cli.js import {defineCliConfig} from 'sanity/cli' import * as dotenv from 'dotenv' export default defineCliConfig({ api: { projectId: 'XXXX', // replace value with your own dataset: 'dev' // replace value with your own }, graphql: [ { id: "production", workspace: "production", }, { id: "dev", workspace: "dev", }, ], })
Feb 4, 2023, 12:40 AM
S
sanity.config.js
// sanity.config.js import { defineConfig } from "sanity"; import { deskTool } from 'sanity/desk' import schemas from './schemas/schema' import { table } from '@sanity/table'; import { colorInput } from "@sanity/color-input"; import deskStructure from './sidebar' import { visionTool } from '@sanity/vision' import * as dotenv from 'dotenv' export default defineConfig([{ title: "XXX Dev", projectId: "XXX ", dataset: "dev", name: "dev", basePath: '/dev', plugins: [deskTool({structure: deskStructure}), visionTool(), table(), colorInput()], tools: (prev) => { // π Uses environment variables set by Vite in development mode if (import.meta.env.DEV) { return prev } return prev.filter((tool) => tool.name !== 'vision') }, schema: { types: schemas, }, document: { newDocumentOptions: (prev, { creationContext }) => { if (creationContext.type === 'global') { return prev.filter((templateItem) => templateItem.templateId != 'settings') } return prev }, actions: (prev, { schemaType }) => { if (schemaType === 'settings') { return prev.filter(({ action }) => !['unpublish', 'delete','duplicate'].includes(action)) } return prev }, }, }, { title: "XXX Prod", projectId: "XXX", dataset: "production", name: "production", basePath: '/production', plugins: [deskTool({structure: deskStructure}), visionTool(), table(), colorInput()], tools: (prev) => { // π Uses environment variables set by Vite in development mode if (import.meta.env.PRODUCTION) { return prev } return prev.filter((tool) => tool.name !== 'vision') }, schema: { types: schemas, }, document: { newDocumentOptions: (prev, { creationContext }) => { if (creationContext.type === 'global') { return prev.filter((templateItem) => templateItem.templateId != 'settings') } return prev }, actions: (prev, { schemaType }) => { if (schemaType === 'settings') { return prev.filter(({ action }) => !['unpublish', 'delete','duplicate'].includes(action)) } return prev }, }, }]);
Feb 4, 2023, 12:40 AM
S
Would anyone have any thoughts on this? π π
Feb 8, 2023, 10:28 PM
D
I donβt see anything obviously wrong, but i also donβt use the rplugin. I know they moved from
process.envπ
import.meta.envwhich you seem to be using. Maybe pop open sanity graphql and peek under the hood? Are you on the latest version?
Feb 8, 2023, 11:04 PM
Are you using a tag when deploying? Seems similar to what was happening here .
Feb 8, 2023, 11:10 PM
S
Thanks both. It was the
https://sanity-io-land.slack.com/archives/C9Z7RC3V1/p1671819526675779
Changing
process.envand
import.meta.envThis post helped:
https://sanity-io-land.slack.com/archives/C9Z7RC3V1/p1671819526675779
Changing
import.meta.env.PRODUCTIONto
import.meta.PRODUCTIONallowed me to deploy graphql. I shall have a play to get the pipelines up and running π
Feb 9, 2023, 12:09 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.