Skip to content

Conversation

@ryanbonial
Copy link
Member

@ryanbonial ryanbonial commented Aug 27, 2025

Description

  • Add optional organizationId parameter for filtering projects by organization
  • Add optional includeMembers parameter
  • Implement parameter-based caching with unique cache keys

What to review

The changes to the projects fetcher store in projects.ts which now supports filtering by organization and toggling member inclusion. The cache key generation now incorporates these parameters to ensure proper caching behavior.

The updated type definitions in useProjects.ts that reflect the new parameter options and return types.

Testing

Added test coverage for the parameter passing behavior. The test in projects.test.ts now verifies that the correct parameters are passed to the list method.

Fun gif

organization

…seProjects hook

- Add optional organizationId parameter for filtering projects by organization
- Add optional includeMembers parameter (defaults to true, breaking change from false)
- Implement parameter-based caching with unique cache keys
- BREAKING CHANGE: useProjects() now returns projects with members by default to
match the Sanity Client
@ryanbonial ryanbonial requested a review from a team as a code owner August 27, 2025 16:12
@ryanbonial ryanbonial requested a review from colepeters August 27, 2025 16:12
@vercel
Copy link

vercel bot commented Aug 27, 2025

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

Project Deployment Preview Comments Updated (UTC)
sdk-docs Ready Ready Preview Comment Aug 28, 2025 7:58pm
sdk-kitchensink-react Ready Ready Preview Comment Aug 28, 2025 7:58pm

@ryanbonial ryanbonial changed the title feat(projects): add organizationId and includeMembers parameters to useProjects hook feat!(projects): add organizationId and includeMembers parameters to useProjects hook Aug 27, 2025
@ryanbonial ryanbonial changed the title feat!(projects): add organizationId and includeMembers parameters to useProjects hook feat(projects): add organizationId and includeMembers parameters to useProjects hook Aug 27, 2025
Copy link
Contributor

@binoy14 binoy14 left a comment

Choose a reason for hiding this comment

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

Comment regarding the default but looks good otherwise

}).observable.pipe(
switchMap((client) => client.observable.projects.list({includeMembers: false})),
switchMap((client) => {
const includeMembers = options?.includeMembers ?? true
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should default to not including members, it can be very slow and we call this on the mount of the SDK, it's also a breaking expectations change which is not really worth changing IMO.

Copy link
Member Author

Choose a reason for hiding this comment

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

I switched this back to defaulting to false

},
fetcher: (instance) => (options?: {organizationId?: string; includeMembers?: boolean}) =>
getClientState(instance, {
apiVersion: API_VERSION,
Copy link
Contributor

Choose a reason for hiding this comment

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

Not really part of your PR but since you are here could you also tag the requests so it's more explicit and not sanity.sdk generic

Copy link
Member Author

Choose a reason for hiding this comment

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

Added

@ryanbonial
Copy link
Member Author

Ready for another review

@ryanbonial ryanbonial requested a review from binoy14 August 28, 2025 20:03
Copy link
Contributor

@binoy14 binoy14 left a comment

Choose a reason for hiding this comment

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

makes sense to me, thanks

@ryanbonial ryanbonial merged commit df4f69c into main Aug 28, 2025
19 checks passed
@ryanbonial ryanbonial deleted the SDK-610/get-projects-by-org branch August 28, 2025 20:20
@squiggler squiggler bot mentioned this pull request Aug 26, 2025
cngonzalez pushed a commit that referenced this pull request Sep 9, 2025
…seProjects hook (#607)

- Add optional organizationId parameter for filtering projects by organization
- Add optional includeMembers parameter
- Implement parameter-based caching with unique cache keys
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