-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
🔮 Feature RequestNew feature or requestNew feature or request
Description
If a dataset is set to private and no/empty API key is given to createClient, the query will silently return null instead of erroring which is confusing and makes it hard to track down the problem, especially for new users.
For example, in the following case it's possible for SANITY_API_TOKEN to be undefined in the environment:
const client = createClient({
projectId: 'xxxxxxx',
dataset: 'production',
apiVersion: '2022-10-21',
useCdn: false,
token: process.env.SANITY_API_TOKEN
})If a query is made, the result will be null:
const result = await client.fetch(groq`
*[_type == "somePage"]
`)
console.log(result)
// nullI understand it might be a security concern to report a failure to access a project or dataset, but on a recent project I've wasted quite a lot of time tracking the issue down, so a hint would be good. Maybe an error if undefined or null is explicitly passed to createClient?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
🔮 Feature RequestNew feature or requestNew feature or request