Skip to content

[sanity-plugin-shopify-assets] Support configuring dataset at plugin and field level #1797

Description

@redasalmi

Which plugin would this affect?

sanity-plugin-shopify-assets

Is your feature request related to a problem?

The plugin currently relies on the active Sanity dataset when fetching Shopify assets.

This is limiting in setups where the dataset used by the Studio is not necessarily the dataset connected to the Shopify store through Sanity Connect.

For example, a project may have multiple datasets connected to the same Shopify store, while a given Studio workspace uses a different dataset for its content. In that case, there is currently no way to tell the plugin which dataset should be used for Shopify asset requests.

Describe the solution you'd like

Add an optional dataset configuration at both the plugin and field level, similar to the existing shopifyDomain option.

At the plugin level:

shopifyAssets({
  shopifyDomain: 'example.myshopify.com',
  dataset: 'production',
})

And at the field level:

defineField({
  type: 'shopify.asset',
  name: 'shopifyAsset',
  options: {
    shopifyDomain: 'example.myshopify.com',
    dataset: 'production',
  },
})

The field-level dataset could override the plugin-level value.

If no dataset is provided, the plugin could keep using the current Studio dataset so existing behavior remains unchanged.

Describe alternatives you've considered

The current alternatives are to make sure the active Studio dataset is also the one connected to the Shopify store, or to maintain a custom version of the plugin.

Neither is ideal for projects using multiple datasets.

Additional context

I'd be happy to work on a PR for this if the proposed API and approach make sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions