sanity-io / vscode-sanity

Visual Studio Code extension for developing applications powered by Sanity.io
MIT License
51 stars 8 forks source link

Extension can't find `sanity.json` in same directory as query file #18

Closed tyler-brandt closed 2 weeks ago

tyler-brandt commented 1 year ago

Hello, I have a folder with some .groq files as well as a sanity.json file, with a directory structure like so image

When I open either client_query.groq or test.groq and attempt to execute a query, I get the following error: ENOENT: no such file or directory, open '/Users/{my-user-name}/.config/sanity/config.json'

I tried creating a symlink to the file at that location and still no luck.

After reviewing the source code for the extension I don't see any obvious reason this isn't working, as my test file and my sanity.json file are siblings. https://github.com/sanity-io/vscode-sanity/blob/4ece39a311251664630518599e799eb1ba99adea/src/config/findConfig.ts#L14

Has anyone else had this issue or see anything I'm doing wrong?

My sanity.json looks like the following

{
  "root": true,
  "project": {
    "name": "my-project-name",
    "basePath": ""
  },
  "api": {
    "projectId": "my-project-id",
    "dataset": "my-data-set"
  },
  "plugins": [],
  "parts": []
}

I'm on MacOS 12.6

VSCode details: Version: 1.76.2 (Universal) Commit: ee2b180d582a7f601fa6ecfdad8d9fd269ab1884 Date: 2023-03-14T17:54:09.061Z Electron: 19.1.11 Chromium: 102.0.5005.196 Node.js: 16.14.2 V8: 10.2.154.26-electron.0 OS: Darwin arm64 21.6.0 Sandboxed: Yes

MartCube commented 1 year ago

I look for the same thing, did you found a way how to do this?

mwritter commented 1 year ago

Im having the same issue, for reference Im using Sanity Studio V3 "sanity": "^3.8.3", not sure if thats part of the problem.

EDIT Looks like I just had my sanity.json file set up wrong, I forgot to add the "api", I also moved my sanity.json to the root of my project, and everything seems to work fine now.

{
  "api": {
      "projectId": "my-project-id",
      "dataset": "my-data-set"
  }
}
mcianc commented 11 months ago

shouldn't the sanity.config.ts be found as used as well? According to the source code only the .JSON file is supported

runeb commented 2 weeks ago

Apologies for the delay on this. The plugin only supported v2 of Sanity which had a different configuration format. We have now updated the plugin to support the newer sanity.cli.js|ts config file.