vendure-ecommerce / storefront-qwik-starter

An e-commerce storefront starter built with Qwik and Vendure
https://qwik-storefront.vendure.io
227 stars 86 forks source link

Unable to add customFields field to product GraphQL query #153

Closed porl closed 7 months ago

porl commented 7 months ago

I am trying to test Vendure and this Qwik starter template for a replacement shop site for our business.

Everything is looking clean, however I am trying to test a custom field (in this case a boolean allowCustomText) on the product entity.

Everything looks good on the Vendure side as far as I can see, however I cannot get the storefront to obtain the custom field.

I have tried adding customFields to the providers/shop/products/products.ts file. The build step generates fine, however trying to view a product triggers the error Field "customFields" of type "ProductCustomFields" must have a selection of subfields. Did you mean "customFields { ... }"?.

Changing it to the following

customFields {
  allowCustomText
}

does not allow the storefront to build - the generate GraphQL documents step gives the error Error 0: Field "customFields" must not have a selection since type "JSON" has no subfields..

Looking at the schema and documentation at http://localhost:3000/shop-api shows in the docs tab the following info for the products->customFields entry:

type ProductCustomFields {
  allowsCustomText: Boolean
}

But the src/generated/schema.graphql file shows

type ProductCustomFields {
 printfulProductId: String
}

and src/generated/schema-shop.graphql shows

type Product implements Node {
  [...]
  customFields: JSON
}

Is this a case of the graphql files not generating correctly (a caching issue perhaps) or am I missing something?

Thanks (sorry for the long post)

porl commented 7 months ago

Okay, I'm stupid. I didn't realise it was using PROD_API which was pointing at the vendure standard demo site.

Sorry for the noise!