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

Missing meta in getMany dataprovider function when using ReferenceArrayInput #8772

Closed
JanSmolko opened this issue Mar 27, 2023 · 1 comment · Fixed by #8803
Closed

Missing meta in getMany dataprovider function when using ReferenceArrayInput #8772

JanSmolko opened this issue Mar 27, 2023 · 1 comment · Fixed by #8803
Labels

Comments

@JanSmolko
Copy link

What you were expecting:
access meta in getMany dataProvider function when it's called by ReferenceArrayInput.

What happened instead:
meta in getMany dataProvider function is empty

Steps to reproduce:
set something like queryOptions={{ meta: { pretty: true } }} in ReferenceArrayInput.
look at getMany fn in dataprovider -> params.meta is empty


Related code:

https://codesandbox.io/p/sandbox/wispy-water-155fuq?welcome=true&file=%2FREADME.md

PostEdit.tsx

...
<ReferenceArrayInput
        {...props}
        perPage={5}
        filter={{ published }}
        queryOptions={{ meta: { pretty: true } }}
>
        <AutocompleteArrayInput
          create={<CreateTag />}
          optionText={`name.${locale}`}
        />
</ReferenceArrayInput>
...

dataProvider.tsx

...
   getMany: (resource, params) => {
    console.log("missing meta", params);
    return dataProvider.getMany(resource, params);
  },
  getList: (resource, params) => {
    console.log("not missing meta", params);
    return dataProvider.getList(resource, params);
  }
...

Environment

  • React-admin version: 4.9.0
  • Last version that did not exhibit the issue (if applicable):
  • React version: 17.0.2
  • Browser:
  • Stack trace (in case of a JS error):
@slax57
Copy link
Contributor

slax57 commented Mar 27, 2023

You are correct. And it's even actually documented that way here:

Use the queryOptions prop to pass options to the dataProvider.getList() query that fetches the possible choices.

However, I'm not sure why we would pass it to getList but not getMany. IMO we should do both.
So I'll qualify this as a bug for now. @djhi can you confirm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants