sanity-io / vscode-sanity

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

Add configuration property to set the Sanity client API version #12

Open brandonburrus opened 2 years ago

brandonburrus commented 2 years ago

Description:

Currently the extension configures a client that uses the default version v1. While this works for most GROQ queries, newer features added in later versions after the versioning schema changed to MM-DD-YYYY don't work because of this. For example, trying to use the pt::text() function causes the query to fail due to the configured client using v1, and not v2021-03-25 or later when the function was introduced to the API.

Proposed Solution:

Add a configuration property to the extension (something like "sanity.apiVersion") that allows users to configure the version.

msafi commented 2 years ago

Theoretically, if you add apiVersion to the api key in sanity.json, it should be picked up by the extension. However, the @sanity/client package used in this extension is version 2, which doesn't seem to support apiVersion. So before you can add apiVersion to sanity.json, the package would need to be updated to version 3.

Personally, I went into .vscode/extensions/sanity-io.vscode-sanity-0.1.4 and upgraded @sanity/client manually. Then added apiVersion to sanity.json.