good-idea / sane-shopify

MIT License
212 stars 15 forks source link

Syncing relationships fails if no prior relationships exist #130

Closed GLips closed 3 years ago

GLips commented 3 years ago

This call in sync-utils/src/sanity/syncRelationships.ts fails if there is no existing relationship.

TypeError: Cannot read property 'some' of undefined

I'm relatively new to Sanity, but it looks like it doesn't return null values if a specific field hasn't been initialized yet. When that's the case, product.collections—which toDoc[bToAKey] evaluates to—is null, and doesn't have access to some().

Previously, it looks like we were setting values if they were missing. Probably need that for new instances again.

good-idea commented 3 years ago

Thanks for the fix, sorry it took me a bit to get to the PR!