Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variant $opts get ignored #232

Closed
LucidityDesign opened this issue Sep 29, 2022 · 3 comments
Closed

Variant $opts get ignored #232

LucidityDesign opened this issue Sep 29, 2022 · 3 comments
Assignees

Comments

@LucidityDesign
Copy link
Contributor

LucidityDesign commented Sep 29, 2022

As I understand the docs getMergeMethod should be called with every variant.
However the function only gets called with root data.

Therefore this variant $opts gets ignored:

$opts:
  array_name: overwrite

See:

function getMergeMethod(method) {

Link to docs:
https://docs.miyagi.dev/how-to/writing-mock-data/#merging-arrays

@mgrsskls
Copy link
Member

Hey @LucidityDesign,

can you give me some example data that is not working as expected?

@LucidityDesign
Copy link
Contributor Author

LucidityDesign commented Sep 29, 2022

This will always set product-1 as first item in the images array:

title: Lorem Ipsum
images:
  - $ref: /elements/image#product-1
$opts:
  images: overwrite

$variants:
  - $name: Multiple images
    title: Pellentesque Dapibus
    $opts:
      images: overwrite
    images:
      - $ref: /elements/image#product-2
      - $ref: /elements/image#product-3
      - $ref: /elements/image#product-1

getMergeMethod is only called in mergeRootDataWithVariationData which is only called with rootData.
I was not able to find another function that respects/handles $opts.

@mgrsskls mgrsskls added the bug Something isn't working label Oct 1, 2022
@mgrsskls mgrsskls self-assigned this Oct 1, 2022
@mgrsskls mgrsskls removed the bug Something isn't working label Oct 8, 2022
@mgrsskls
Copy link
Member

mgrsskls commented Oct 8, 2022

@mgrsskls mgrsskls closed this as completed Oct 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants