Skip to content

Conversation

@ryanbonial
Copy link
Member

@ryanbonial ryanbonial commented May 6, 2025

Description

This PR adds support for the experimental resource API in the Sanity client. It enables clients to use the new resource-based API endpoints by setting useExperimentalResource: true in the Sanity config.

The implementation:

  • Adds a new useExperimentalResource flag to the SanityConfig interface
  • Updates the client store to detect when this flag is set and configure the client accordingly
  • Ensures proper handling of the experimental resource settings when creating client instances
  • Adds explicit useProjectHostname: true to specific API calls that aren't yet compatible with the experimental resource API

What to review

  • The logic in getClient that determines when to use experimental resources
  • How the configuration is passed from the Sanity config to the client options
  • The temporary useProjectHostname: true settings in datasets, project, and query stores
  • The updated type definitions for client configuration options

Testing

The changes have been tested with the kitchensink-react app, which now has useExperimentalResource: true enabled for both test configurations.

Fun gif

Experimenting with science

@vercel
Copy link

vercel bot commented May 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sdk-docs ❌ Failed (Inspect) Aug 6, 2025 9:26pm
sdk-kitchensink-react ❌ Failed (Inspect) Aug 6, 2025 9:26pm

@github-actions
Copy link

github-actions bot commented May 6, 2025

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 95.7% (🎯 95%) 6569 / 6864
🟢 Statements 95.7% (🎯 95%) 6569 / 6864
🟢 Functions 95.6% (🎯 95%) 326 / 341
🟢 Branches 94.61% (🎯 90%) 2056 / 2173
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/core/src/client/clientStore.ts 81.95% 79.41% 100% 81.95% 123, 173-192, 206-209
packages/core/src/config/sanityConfig.ts 100% 100% 100% 100%
packages/core/src/datasets/datasets.ts 91.66% 57.14% 100% 91.66% 15-16
packages/core/src/project/project.ts 94.11% 50% 100% 94.11% 14-15
packages/core/src/query/queryStore.ts 100% 98.27% 100% 100%
Generated in workflow #1409 for commit 5eed2db by the Vitest Coverage Report Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant