Error deploying GraphQL API in Sanity v3 project
2 replies
Last updated: Dec 16, 2022
V
Hi, I’m trying to update v2 project to v3. So far going nicely, except when I run I get an error.
My sanity.cli.ts:
Sanity.config.ts
When I run
Running
sanity graphql deploy --dataset test --tag default
$ sanity graphql deploy --dataset test --tag default WARN: More than one API defined, and --dataset/--tag is specified WARN: This will use the specified flag for ALL APIs! ? Continue with flag override for all APIs? Yes Error: Multiple GraphQL APIs with the same dataset and tag found (test/default) at Object.deployGraphQLApiAction [as default] (~/veri/narrative-content/node_modules/sanity/lib/_chunks/deployApiAction-6e38bde5.js:1555:13)
export default defineCliConfig({ api: { projectId: "xxxxxx", }, graphql: [ { workspace: "production", }, { workspace: "test", }, ], });
export default defineConfig([ { name: "test", // Identifier used to reference configuration title: "test", // Name displayed in Sanity studio dropdown projectId: "xxxxxx", default: true, // Which config to open by default in Sanity studio dataset: "test", basePath: "/test", // URL path plugins: [deskTool(), media(), muxInput({ mp4_support: "standard" })], schema: { types: schemaTypes, }, }, { name: "production", // Identifier used to reference configuration title: "production", // Name displayed in Sanity studio dropdown projectId: "xxxxxx", dataset: "production", basePath: "/production", // URL path plugins: [deskTool(), media(), muxInput({ mp4_support: "standard" })], schema: { types: schemaTypes, }, }, ]);
When I run
$ sanity graphql deploy --helpit only lists
--dry-run
--forceand
--apias options. Is
--datasetand
--tagno longer supported from cli?
Running
sanity graphql deployfirst prompts me to deploy
productionand then
testand this way deploying works just fine. I’d just like to specify as arguments which env I want to deploy.
Dec 16, 2022, 8:27 AM
V
And Immediately I get it 🤦♂️
I need to define id for each graphQL api like this:
And then
I need to define id for each graphQL api like this:
export default defineCliConfig({ api: { projectId: "xxxxxx", }, graphql: [ { id: "production", workspace: "production", }, { id: "test", workspace: "test", }, ], });
yarn sanity graphql deploy --api test
Dec 16, 2022, 8:30 AM
V
$ yarn sanity graphql deploy --api test --tag moo WARN: More than one API defined, and --tag is specified WARN: This will use the specified flag for ALL APIs! ? Continue with flag override for all APIs? Yes Deploying only specified APIs: test ⚠ Generating GraphQL API: test/moo ? Do you want to enable a GraphQL playground? Yes ✔ Generating GraphQL API: test/moo Project: xxxxx Dataset: test Tag: moo URL: <https://xt399tbr.api.sanity.io/v1/graphql/test/moo> ✔ Deployed! :sparkles: Done in 38.58s.
I feel the message
This will use the specified flag for ALL APIs!
Also the --tag property seems to be working still, but it’s not listed in options with
sanity deploy --help
Dec 16, 2022, 8:34 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.