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

[BUG] MUI Inferencer sets all fields to required #5895

Closed
otakueadwine opened this issue Apr 26, 2024 · 1 comment
Closed

[BUG] MUI Inferencer sets all fields to required #5895

otakueadwine opened this issue Apr 26, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@otakueadwine
Copy link

Describe the bug

We use a graphql setup with an inferencer to generate CRUD screens using Material UI.
When using the inferencer all the form fields get flagged as 'required'. Since we want to automate the project as much as possible, having to manually remove these required flags is very undesired.
Looking at the source code you can find some hardcoded config on the form fields:

https://github.com/refinedev/refine/blob/master/packages/inferencer/src/inferencers/mui/create.tsx#L141
https://github.com/refinedev/refine/blob/master/packages/inferencer/src/inferencers/mui/create.tsx#L232

https://github.com/refinedev/refine/blob/master/packages/inferencer/src/inferencers/mui/edit.tsx#L152
https://github.com/refinedev/refine/blob/master/packages/inferencer/src/inferencers/mui/edit.tsx#L246
https://github.com/refinedev/refine/blob/master/packages/inferencer/src/inferencers/mui/edit.tsx#L287

Steps To Reproduce

Have a resource with some optional fields
Create CRUD screens with the inferencer
Open the Create screen
Save blank form
All fields will be flagged red

Expected behavior

Expecting the 'required' flag to only be added on resource fields of type 'NON_NULL' (or those marked with "!").

Packages

"@refinedev/core": "^4.49.0",
"@refinedev/graphql": "^6.5.0",
"@refinedev/inferencer": "^4.6.0",
"@refinedev/mui": "^5.14.5",
"@refinedev/react-router-v6": "^4.5.7",

Additional Context

No response

@otakueadwine otakueadwine added the bug Something isn't working label Apr 26, 2024
@aliemir
Copy link
Member

aliemir commented Apr 30, 2024

Hey @otakueadwine, understood the need here, yet the Inferencer components' outputs are designed to be edited rather than using it as is. We're marking all inferred fields as required to make sure we're not breaking the interacted APIs with corrupted data.

As a workaround, you can create your own inferencer components, we're exporting all the required methods and components within our @refinedev/inferencer package and you can copy-paste the source code to implement your own templates.

Unfortunately for now we're not planning changing this behavior of Inferencer components. Let us know if we can help with any other issues 🙏

@aliemir aliemir closed this as not planned Won't fix, can't repro, duplicate, stale Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants