✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Troubleshooting GraphQL deployment in Sanity monorepo

28 replies
Last updated: Aug 19, 2020
hey everyone, i'm trying out Sanity for the first time, I made changes to fields in Studio and would like to redeploy the GraphQL API by running
npm run graphql-deploy
however, its stuck on
lerna info Executing command in 1 package: "npm run graphql-deploy"
. Is this an issue or I gotta keep waiting? 😄
Aug 18, 2020, 12:05 AM
It shouldn’t take that long. Quick synopsis from off-slack conversation: Running the Gatsby Blog Starter and sanity-plugin-markdown.
Did the graphql deploy work in the beginning and start failing later or has it never worked?
Aug 18, 2020, 12:20 AM
I've never run the graphql-deploy command before now
Aug 18, 2020, 12:21 AM
umm so i tried directly in the studio directly locally and it deployed
Aug 18, 2020, 12:22 AM
just now
Aug 18, 2020, 12:23 AM
This just started working again on the monorepo when i ran the graphql-deploy command again. :mindblown: 😄
Aug 18, 2020, 12:25 AM
I guess we wait till it pops again. Thanks for the time
user T
Aug 18, 2020, 12:25 AM
That sort of thing will never sit right with me! Glad it’s working, sorry it wasn’t!
If anything else comes up, let me know!
Aug 18, 2020, 12:26 AM
user C
I had the same problem and I fixed it by -1.
cd studio
sanity graphql deploy
You need to have installed sanity's cli if you haven't already -

npm install -g @sanity/cli
Aug 18, 2020, 2:53 AM
user P
i too have problem in that ,i always ran graphql. deploy on root folder ?is that wrong .
Aug 18, 2020, 12:18 PM
Theoretically you should be able to run
npm run graphql-deploy
from the root and have it work. I tested it last night and it didn’t give any issues, but i’d be curious about the circumstances folks are having issues running from the root. I don’t know a ton about lerna, but if there’s a systemic issue, i’d love to get it sorted out
Aug 18, 2020, 12:52 PM
hey !
user T
.i am adding new fields in the schemas and running the command
npm run graphql-deploy
,but i always get error .
Aug 18, 2020, 4:14 PM
Not sure if this will be THE solution, but it looks like if you modify the
script in the main package.json file to this instead it will work:

    "graphql-deploy": "lerna run graphql-deploy --parallel",
This adds the parallel flag. My current theory is that it’s hanging up when it doesn’t find a
command in the
directory and the parallel flag lets it run both and not hang
Aug 18, 2020, 4:39 PM
"graphql-deploy": "sanity graphql deploy --playground",
Aug 18, 2020, 4:44 PM
i have this code already in package.json in studio folder , i will replace and try that
Aug 18, 2020, 4:45 PM
that should stay in the studio folder. If you change the code in the root package.json to the snippet i put, it will run the code in your studio folder properly
Aug 18, 2020, 4:45 PM
the issue is more “how to run from the root directory.” Running the
command from your Studio directory will work just fine. If you want the shortcut of not having to move into your studio folder, you can update the root package.json
Aug 18, 2020, 4:46 PM
got it ! thank you i have changed it. please do follow up the thread about how it goes , i''m new to sanity ,so i'm having hard time with the failure of npm commands
Aug 18, 2020, 4:51 PM
Will do. If this ends up being the solution we go with, we’ll also make sure all our starters are updated
Aug 18, 2020, 4:51 PM
i probably have messed up with something else here's the message
Aug 18, 2020, 5:07 PM
can i share my repo and locate the files where i made the changes so that you can see whats wrong
Aug 18, 2020, 5:09 PM
Aug 18, 2020, 5:10 PM
studio web this are files that contains the code ,i have deployed grapl-ql and run frontend up to this point and worked fine
Aug 18, 2020, 5:24 PM
this is changes made in studio file
Aug 18, 2020, 5:26 PM
i can preview the changes made (i.e extra image field added)and publish it but as i stop the developement sever and run
npm run graphql-deploy
the errors i showed previously showed up.
Aug 18, 2020, 5:28 PM
I ran this in a small project and the schema should be fine. Can you try running it from your studio directory?
cd studio
npm run graphql-deploy
I’m curious to see if this is Lerna getting in the way or something somewhere else in code
Aug 18, 2020, 6:06 PM
Aug 18, 2020, 6:10 PM
Nope not working in studio folder dir ,this image shows the error
Aug 19, 2020, 7:00 AM
error msg in root folder: failed at the sanity-gatsby-blog@1.0.14 graphql-deploy:
lerna run graphql-deploy --parallel
Aug 19, 2020, 8:33 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.

Was this answer helpful?