You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following introduces a "source" concept that can be used to query
different types of resources. The long-term vision here is:
- `SanityInstance` should no longer be an inherited tree structure.
This will rather be a single object which contains global information
(e.g. token). There will be no re-use of any state across `SanityInstance`.
- All hooks/functions which works on documents will also accept a
`source` parameter. This is a single parameter (instead of the
`projectId`/`dataset`) tuple that can easily be passed around.
If you're making higher-order helpers you just need to accept a
single source object.
- There are top-level functions which constructs these `source` objects.
In the future these objects will also contain type information.
These should also be owned by `@sanity/client`. In this PR we're
mapping it to the existing experimental resource API, but the
intention is for `@sanity/client` to provide a proper source-based API
which we're re-exporting/using here in SDK.
- We'll introduce a new "default source" context as well. This is
_outside_ of the `SanityInstance` so that you can change it.
- There will be no special support for placing multiple sources in the
context. The user can always define their own context if they want to
have access to multiple `source` objects. This gives them more
flexibility in how to structure their applications.
- If you have fully static data sources you can always hard-code them in
single file: `export const PRODUCTS = datasetSource(projectId, "datasets")`.
0 commit comments