0.3.2 • Published 2 years ago
@1of1studio/shopify-sanity-sync v0.3.2
@1of1studio/shopify-sanity-sync
API
Initialise as you would @sanity/client
for read + write use.
import { SanitySyncClient } from '@1of1studio/shopify-sanity-sync'
const client = new SanitySyncClient({
projectId: 'your-project-id',
dataset: 'bikeshop',
apiVersion: '2021-03-25',
token: 'sanity-auth-token',
})
Create or Update
import { formatShopifyDocument } from '@1of1studio/shopify-sanity-sync'
const documentToCreateOrUpdate = formatShopifyDocumnet('collection', {
id: 'Z2lkOi8vc2hvcGlmeS9Db2xsZWN0aW9uLzM1ODUwMzM1MDQ5Ng==',
handle: 'lighting',
title: 'Lighting',
})
await client.createDraftOrUpdate(documentToCreateOrUpdate)
Delete
import { convertShopifyDocumentId } from '@1of1studio/shopify-sanity-sync'
const documentIDToDelete = convertShopifyDocumentId(
'Z2lkOi8vc2hvcGlmeS9Db2xsZWN0aW9uLzM1ODUwMzM1MDQ5Ng=='
)
await client.delete(documentIDToDelete)
To Do
- Setup Sanity and Shopify environments for setup/teardown in tests.