113 Sanity

113 Sanity

Table of Contents
┌─(~/Desktop/Work/FutureTek Project/vO)────────────────────────────(atulyaraaj@pavilion-pc:pts/1)─┐
└─(13:12:12)──> npm install -g @sanity/cli                                          ──(Mon,Jan13)─┘

added 472 packages in 24s

48 packages are looking for funding
  run `npm fund` for details
┌─(~/Desktop/Work/FutureTek Project/vO)────────────────────────────(atulyaraaj@pavilion-pc:pts/1)─┐
└─(13:12:42)──> sanity init                                                         ──(Mon,Jan13)─┘
✓ You are logged in as masterhutirar@tutanota.com using Email
✓ Fetching existing projects

? Create a new project or select an existing one Create new project
? Your project name: futureTek
Your content will be stored in a dataset that can be public or private, depending on
whether you want to query your content with or without authentication.
The default dataset configuration has a public dataset named "production".
? Use the default dataset configuration? Yes
✓ Creating dataset
? Project output path: /home/atulyaraaj/Desktop/Work/FutureTek Project/vO/futuretek
? Select project template Blog (schema)
? Do you want to use TypeScript? Yes
✓ Bootstrapping files from template
✓ Resolving latest module versions
✓ Creating default project files
? Package manager to use for installing dependencies? yarn
Running 'yarn install'
yarn install v1.22.22
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "@sanity/vision > @sanity/ui@2.11.1" has unmet peer dependency "react-is@^18 || >=19.0.0-0".
warning "@sanity/vision > @uiw/react-codemirror@4.23.7" has unmet peer dependency "@babel/runtime@>=7.11.0".
warning "@sanity/vision > @uiw/react-codemirror@4.23.7" has unmet peer dependency "@codemirror/theme-one-dark@>=6.0.0".
warning "@sanity/vision > @uiw/react-codemirror@4.23.7" has unmet peer dependency "codemirror@>=6.0.0".
warning "@sanity/vision > @uiw/react-codemirror > @uiw/codemirror-extensions-basic-setup@4.23.7" has unmet peer dependency "@codemirror/lint@>=6.0.0".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 50.24s.

Success! Now, use these commands to continue:

First: cd /home/atulyaraaj/Desktop/Work/FutureTek Project/vO/futuretek - to enter project’s directory
Then: yarn dev - to run Sanity Studio

Other helpful commands
npx sanity docs - to open the documentation in a browser
npx sanity manage - to open the project settings in a browser
npx sanity help - to explore the CLI manual
┌─(~/Desktop/Work/FutureTek Project/vO)────────────────────────────(atulyaraaj@pavilion-pc:pts/1)─┐
└─(13:14:57)──> 
┌─(~/Desktop/Work/FutureTek Project/vO/futuretek)──────────────────(atulyaraaj@pavilion-pc:pts/1)─┐
└─(13:15:59 on main)──> yarn dev                                                    ──(Mon,Jan13)─┘
yarn run v1.22.22
$ sanity dev
✓ Checking configuration files...
Sanity Studio using vite@5.4.11 ready in 2086ms and running at http://localhost:3333/

You will need a Sanity account too. The studio asks to login.

alt text

This will the dashboard post login

Sanity seems to be closely coupled with the Home Sanity product.

Deploying Sanity:

sanity graphql deploy                                 130 ↵ ──(Mon,Jan13)─┘

⠧ Generating GraphQL API: production/default
HttpError: Request returned HTTP 401
    at getUrlHeaders (/home/atulyaraaj/Desktop/Work/FutureTek Project/vO/futuretek/node_modules/sanity/lib/_chunks-cjs/deployApiAction.js:22:19)
    at async getCurrentSchemaProps (/home/atulyaraaj/Desktop/Work/FutureTek Project/vO/futuretek/node_modules/sanity/lib/_chunks-cjs/deployApiAction.js:1580:93)
    at async Object.deployGraphQLApiAction [as default] (/home/atulyaraaj/Desktop/Work/FutureTek Project/vO/futuretek/node_modules/sanity/lib/_chunks-cjs/deployApiAction.js:1443:9)

I apologize for the error you’re encountering. It seems there’s an authentication issue when trying to deploy the Sanity GraphQL API. Let’s troubleshoot this step by step:

  1. First, ensure you’re logged in to the correct Sanity account:
sanity login

Follow the prompts to log in if needed.

  1. Verify that you’re in the correct Sanity project directory. Run:
sanity debug

This will show you information about the current project, including the project ID.

  1. Make sure your Sanity CLI is up to date:
npm install -g @sanity/cli@latest
  1. Check if your Sanity project has the necessary CORS origins set up. Run:
sanity cors list

If your development URL (e.g., http://localhost:3000) is not listed, add it:

sanity cors add http://localhost:3000
  1. Verify that your Sanity project’s API settings allow GraphQL deployment. In your Sanity project’s dashboard (https://www.sanity.io/manage), go to API settings and ensure that GraphQL API is enabled.
  2. If the issue persists, try logging out and logging back in:
sanity logout
sanity login
  1. After these steps, try deploying the GraphQL API again:
sanity graphql deploy

If you’re still encountering issues, please provide the output of sanity debug (make sure to remove any sensitive information), and I can help you further.

Also, as an alternative, you can deploy the GraphQL API from the Sanity project dashboard:

  1. Go to https://www.sanity.io/manage
  2. Select your project
  3. Navigate to the “API” tab
  4. Under “GraphQL API”, click on “Deploy GraphQL API”

This method bypasses any local authentication issues you might be facing with the CLI.

Let me know if any of these steps resolve the issue or if you need further assistance.

Here Sanity have a cloud dependencies, which I don’t think is good if you want a complete control over data.

  1. You define document schema
  2. Create data in document
  3. Access the Sanity data using GQL from the cloud storage.