good-idea / sane-shopify

MIT License
212 stars 15 forks source link

feat(sync-utils): set document ID in Sanity to match shopifyId #166

Open nrgnrg opened 3 years ago

nrgnrg commented 3 years ago

closes #165

This commit sets the document ID in Sanity for newly created documents to be the same as the ShopifyID.

The only difference between the ID's is the = from the ShopifyID is removed as this fails validation on Sanity's end.

Existing documents are not changed.

Doing this allows us to use the IDFilter when performing a ShopifyProduct query on Sanity using GraphQl with an ID returned directly from Shopify, for example when loading a users checkout.

It would make sense to handle Collection ID's in the same way. Happy to create a PR for that too.

good-idea commented 3 years ago

Thank you! This will be very helpful ~ I'm going to run a test locally to make sure there are no breaking changes to existing IDs.