ndimatteo/HULL

Encountered a field that is not defined in the schema.

myeljoud opened this issue · 9 comments

After cloning the studio locally and linking it with my Shopify store, the products won't show up correctly. I have tried to make it work but could not, it took me days. Now I need some help so I can proceed.

Screen Shot 2022-07-27 at 20 30 44

Screen Shot 2022-07-27 at 20 30 58

Screen Shot 2022-07-27 at 20 31 06

Apparently, it is a schema error.

Here is some information that might be useful or relevant:

  • I have the easy setup and the Next app works fine with the project ID included in the sanity.json by default, but it does not work with my studio project ID, it shows an error of Home Page
  • I tried cloning the sanity connect studio template, which works as expected.

Screen Shot 2022-07-27 at 20 36 10

Any help is appreciated, and thanks for the excellent template!

Hey there @medyahyejoud! It looks like you're using the Sanity Connect app (created by Sanity) to sync data. This is incompatible with HULL, which uses its own sync solution using custom Next.js API endpoints with Shopify webhooks.

This is why the data isn't coming in properly for you when using HULL! Please try following steps #2 and #3 of the readme to properly set up Shopify for syncing.

Hello, @ndimatteo thanks for the quick answer, yes I installed Sanity Connect and it is what causes the problem.
I'm doing it all together again, I wanted to set up a studio separate from my Next app because I'm doing the App with custom design and custom modules, and trying to link the studio with the Next app and a React Native app.

Is there a way to separate them while syncing the products and a standalone Studio? I want to understand where the syncing happens and is shown and what parts of the template are critical for the sync process.

And thanks again.

No problem @medyahyejoud!

The main syncing (create/update) happens through this API route, which receives the Shopify webhook payload for the product.

You can still run your studio separately from the Next app. The API routes are only used for the Shopify webhooks to handle actually writing the data to your Sanity dataset (much like the Sanity Connect app).

You could always pull these API routes out and put them on their own instance if you truly want that part to be separate from your main Next.js application.

I hope that helps!

Good evening @ndimatteo, hope you had a wonderful day.

Thanks a lot, that worked well for me I separated the two applications. After syncing some products I noticed that the images are not synced, I noticed that the sync should be triggered by this route and this route is linked with action resolver in Sanity Studio, but the images are not syncing maybe I'm missing some queue or something

Glad that worked @medyahyejoud!

Just to clarify: images are synced from Sanity -> Shopify (not the other way around). The Sanity Action that triggers this creates the URL to ping that API route you linked (/api/shopify/product-images) based on the domain set in the "General Settings" document. You can see that here: https://github.com/ndimatteo/HULL/blob/main/studio/parts/resolve-actions.js#L68-L75

Since you separated out your API routes from your storefront account, it's likely that it's trying to ping your storefront domain name with that API route, instead of your separate application. Can you confirm if that's the case?

If so, I'd suggest modifying the action to pull the domain from another field (perhaps you could add a field in the settings for this, something like: Shopify Sync Domain, and use that in the action to create the correct link.

Once you do that, it should take any cartPhotos associated with the product and push them to Shopify to correspond with their matched variant.

Hey @ndimatteo, I already have a lot of products in Shopify with their corresponding images and description, I just need a way to pull those images and their descriptions to Sanity, not the other way around. As for the images syncing from Sanity -> Shopify.

Thanks.

Gotcha @medyahyejoud! Since HULL takes a different approach to handling presentation data, you'll need to adapt the sync function to meet your needs with photos.

The webhook payload that the sync function ingests includes an images array, that you could parse to upload the assets to Sanity and then patch the product with image references.

It's not a small task, but shouldn't be too difficult to do. Beyond the Sanity client docs for uploading assets, you can also see how Midway (another headless Shopify starter) handles uploading Shopify images and associating them with documents here: https://github.com/ctrl-alt-del-world/midway/blob/master/web/src/lambda/shopify-sync.ts#L98-L115

I'm also going to mark this as closed, as the original issue is resolved, and this is a customization that goes beyond what HULL is responsible for at this time.

Good luck, and feel free to open a new issue if something specific comes up in relation to core HULL functionality! 🤘

Thanks a bunch, guys that were a lot of help, good luck!