medusajs / gatsby-starter-medusa

A production-ready Gatsby starter for Medusa

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Valid products cause errors

rjhllr opened this issue · comments

Currently, products that are valid / "creatable" in the admin still crash this starter. This has to do with:
No 1: Attributes being expected in GraphQL type definitions and omitted from the response
image
This is valid for the weight too - not setting one on a single product in the backend crashes this starter, see:
image

No 2 More obvious templating/access errors (e.g. image component not checking for the value of current here) - current is unset for products w/o images.

While I can provide fixes for the second issue no problem I'm not sure how to approach issue No. 1. The Gatsby CLI output shown in the second image has some suggestions and links the docs page here but I don't really know that much about Gatsby yet so I'm just raising the issue for now.

Hi, @rjhllr

Thanks for pointing it out! A quick way to fix this would be to remove weight from the GraphQL query found at templates/product.js on line 141.

I will be opening a PR to our gatsby-source-plugin (which this starter uses to pull products) that will update the GraphQL schema so we can avoid these types of errors moving forward. It might first be released as part of our next release of Medusa, so for know I would suggest you simply remove the fields that dont exist on any of your products as described above.

If you want to open a PR for the issue you mentioned regarding the current image, that would be greatly appreciated, and otherwise let me know 😄