good-idea / sane-shopify

MIT License
212 stars 15 forks source link

set document ID in Sanity to match shopifyId #165

Open nrgnrg opened 3 years ago

nrgnrg commented 3 years ago

Is your feature request related to a problem? Please describe.

This is probably only useful in a handful of edge cases but I'm using a normalised cache on the Sanity GraphQL API and when I get a users checkout from Shopify I only have the Shopify ID's. This makes it very difficult to query my cache which although I have keyed using Shopify ID's, can't translate an allShopifyProducts query into a key for an item in the cache.

Describe the solution you'd like

If the document ID in Sanity matched the Shopify ID we would be able to perform GraphQl ShopifyProduct queries with ID's returned from Shopify API's. This would be able to translate directly into a key for the cache.

I don't think there are any downsides to using the Shopify ID in place of an auto generated Sanity ID and it would be a very simple change to make since Sanity allows setting custom ID's using client.create.