Discussion on setting up Sanity with Gatsby and resolving a "graphql is not a sanity command" error.
26 replies
Last updated: Aug 5, 2020
A
i keep getting this error
while just following this instruction here:
https://github.com/sanity-io/gatsby-source-sanity
What am I missing? hmm actually migrating existing Gatsby isn’t as straightforward as I thought it would be in Sanity
Error: "graphql" is not a sanity command. See "sanity --help"
https://github.com/sanity-io/gatsby-source-sanity
What am I missing? hmm actually migrating existing Gatsby isn’t as straightforward as I thought it would be in Sanity
Aug 5, 2020, 4:19 PM
J
Hey
user U
! What version of the sanity CLI are you running? Are you sure you're on the latest version? Running sanity versionsshould let you know.
Aug 5, 2020, 4:45 PM
A
hey it says 1.149.19 (up to date)
Aug 5, 2020, 4:46 PM
A
i think maybe bcos i ran sanity graphql deploy on a gatsby repo (not sanity)?
Aug 5, 2020, 4:46 PM
K
user U
I think that would do it!Aug 5, 2020, 4:47 PM
J
Yes, seems like it throws that error when running outside a Studio folder
Aug 5, 2020, 4:48 PM
J
not very helpful
Aug 5, 2020, 4:48 PM
A
Got it thanks! any quick tips if i already have a full-blown gatsby how do i,
sanity initon empty path then import in Gatsby? i've been going thru docs but i'm like beginner/novice so there are a lot of jargons flying above my heads 😅
Aug 5, 2020, 4:50 PM
K
user U
, what do you mean by that? I don't believe you don't have to keep your Sanity codebase in the same repository as your Gatsby codebase at all. (I think some people just choose to for tidiness.)Aug 5, 2020, 4:53 PM
K
Also, from what I can tell, the Sanity CLI could not care less whether you are using Git to track the folders you're running it against.
Aug 5, 2020, 4:54 PM
K
I believe that, once you've
init-ed a project into a folder on your computer, further work with the Sanity CLI just looks for a
sanity.jsonin your command line's present working directory and figures out which Sanity Project to communicate with based on the contents of that file.
Aug 5, 2020, 4:55 PM
K
initjust helps you set up that file (and other related files).
Aug 5, 2020, 4:55 PM
A
oh wow i thought you have to do that! basically there is a gap in my knowledge trying to see starter examples and what i have at hand (an existing gatsby with markdown/netlifycms).
Aug 5, 2020, 4:56 PM
K
Yeah, I always struggle with starter examples, too.
Aug 5, 2020, 4:56 PM
K
It's so hard to tell what's part of "how things really work" and what's "just there to make a starter project feel usable."
Aug 5, 2020, 4:56 PM
K
If you're running Studio in Sanity's cloud, you're kind of just using your local machine as a way to put configuration files into it that manage.sanity.io doesn't let you set up directly.
Aug 5, 2020, 4:57 PM
A
yes exactly this! i think you just made it click for me. Thank you so much. I hope you know how helpful and time-saving this is
Aug 5, 2020, 4:58 PM
A
wait sorry that last part. I read it out loud multiple times
Aug 5, 2020, 4:58 PM
A
i dont think i get it
Aug 5, 2020, 4:58 PM
K
Let me DM you a blog post I'm working on.
Aug 5, 2020, 5:00 PM
A
so if i understand this correctly (roughly), i can set up sanity locally and sync it with the cloud, and then use those content to be sourced in my existing gatsby site?
Aug 5, 2020, 5:00 PM
A
sure!
Aug 5, 2020, 5:00 PM
K
so if i understand this correctly (roughly), i can set up sanity locally and sync it with the Sanity cloud, and then use those content to be sourced in my existing gatsby site in a different site-hosting cloud?So far, that's exactly what I've done!
Aug 5, 2020, 5:01 PM
A
ah okay got it now. Thanks for walking me through this really appreciate it
Aug 5, 2020, 5:02 PM
K
No problem! If you run into any other issues, I recommend trying a "hello world" Sanity project and a corresponding "hello world" Gatsby site like I was doing with the
Xyzzywork. Like ... see how much you can & can't break with Sanity+Gatsby from scratch. 😉
Aug 5, 2020, 5:04 PM
K
All right, off to lunch -- and looks like off to bed for you!
Aug 5, 2020, 5:05 PM
A
alrighty thanks again! yes im off to bed but at least i wont be staring the ceiling thinking about these. Cant wait for weekend to test these out! Thanks again
user K
!Aug 5, 2020, 5:06 PM
Sanity– build remarkable experiences at scale
The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.