Skip to content

Conversation

@judofyr
Copy link
Contributor

@judofyr judofyr commented Sep 22, 2025

Description

(Note: There should be no changes to the React package here.)

This changes the core functions for working with dataset/project to explicitly require a project ID and not look into the SanityInstance configuration. This is part of a future where we only have a single SanityInstance and instead every function can be invoked on arbitrary projectId/datasets without being configured explicitly.

What to review

Testing

Fun gif

@vercel
Copy link

vercel bot commented Sep 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
sdk-docs Ready Ready Preview, Comment Dec 15, 2025 0:31am
sdk-kitchensink-react Ready Ready Preview, Comment Dec 15, 2025 0:31am

Copy link
Contributor Author

judofyr commented Sep 22, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@judofyr judofyr force-pushed the holm/require-project-id branch from 2cbcac0 to 8b5e9b8 Compare September 23, 2025 14:03
@judofyr judofyr force-pushed the holm/require-project-id branch from 8b5e9b8 to 5c97111 Compare September 25, 2025 10:34
@judofyr judofyr force-pushed the holm/require-project-id branch from 5c97111 to 0833fe0 Compare December 15, 2025 12:11
@judofyr judofyr self-assigned this Dec 15, 2025
@judofyr judofyr marked this pull request as ready for review December 15, 2025 12:55
@judofyr judofyr requested a review from a team as a code owner December 15, 2025 12:55
@judofyr judofyr requested review from cngonzalez and removed request for a team December 15, 2025 12:55
@judofyr judofyr mentioned this pull request Dec 16, 2025
Copy link
Member

@cngonzalez cngonzalez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less sure about this one because it's technically a breaking change. I'm unclear on how vital it is to make this change now

export const datasets = createFetcherStore({
name: 'Datasets',
getKey: (instance, options?: ProjectHandle) => {
const projectId = options?.projectId ?? instance.config.projectId
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How strongly do we feel about continuing checking the instance in this PR and come back to it later in a broader breaking change? There are plenty of other hooks that still use the instance at this point in the stack, and this will throw anyway with a configuration that's just a Media Library source (I think)

(I also think there are a number of issues that will crop up now if you try to make an SDK app with just a Media Library source)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, this came from me basically uncommenting the definition of instance.config.projectId and trying to get rid of them. I think we can workaround this even with a new "named sources" concept by basically having a helper function like this:

function getProjectId(sources) {
  // Prioritize default source:
  if ('projectId' in sources.default) return sources.default.projectId
  // Loop over all sources, find the projectId, if there's only one => return it
  // If there's multiple => Error
}

I can look into introducing this separately. I will close this and rather rebase the rest on top of latest main.

@judofyr judofyr closed this Dec 19, 2025
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.

2 participants