vendure-ecommerce / vendure

The commerce platform with customization in its DNA.
https://www.vendure.io
Other
5.61k stars 993 forks source link

customFields null on graphQl query collection #2171

Closed getwebM closed 7 months ago

getwebM commented 1 year ago

Describe the bug customFields is null on graphQl query collection

Product with customFields: image

Query: image

Response: image

To Reproduce Steps to reproduce the behavior:

  1. Create a product with custom Fields
  2. Add Product to collection
  3. Query Collection with productVariants
  4. See customFields are empty

Expected behavior List of customFields as JSON

Environment (please complete the following information):

daviddarx commented 8 months ago

I have the same problem: my custom fields are exposed for the products correctly with the product or through the activeOrder queries, but missing through the order and orderByCode queries.

michaelbromley commented 8 months ago

I think the problem here (in both cases) is that the custom fields are being defined on the Product entity, but both the collection and (I am guessing) your order queries are actually querying ProductVariant rather than Product.

For example, to get the custom fields of the Product from the activeOrder query you would do:

query {
  activeOrder {
    id
    lines {
      productVariant {
        product {
          customFields {
            myCustomField
          }
        }
      }
    }
  }
}
daviddarx commented 8 months ago

Hi @michaelbromley ,

Thanks for your quick feedback. Hum, I guess my query already was correct, see, if I query the product directly by ID, I get its shortname:

01_product

On the other hand, If I have the product in my order lines with order or orderByCode, the shortname is there null.

02_order 03_orderByCode

Am I missing something? Thanks in advance!

michaelbromley commented 8 months ago

@daviddarx ok yeah your queries look correct so this seems like a potential bug then. I will investigate at the next opportunity.

Alternatively let's try putting a bounty on it to incentivize others to have a go at solving it:

/bounty $40

algora-pbc[bot] commented 8 months ago

💎 $40 bounty • Vendure

Steps to solve:

  1. Start working: Comment /attempt #2171 with your implementation plan
  2. Submit work: Create a pull request including /claim #2171 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to vendure-ecommerce/vendure!

Add a bounty • Share on socials

Attempt Started (GMT+0) Solution
🔴 @jemiluv8 Jan 16, 2024, 4:51:27 PM WIP
🔴 @oliverqx Jan 23, 2024, 4:14:20 PM #2644
daviddarx commented 8 months ago

@michaelbromley Great thanks!

oliverqx commented 8 months ago

/attempt #2171

algora-pbc[bot] commented 8 months ago

💡 @oliverqx submitted a pull request that claims the bounty. You can visit your bounty board to reward.