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

ra-data-graphql-simple UPDATE_MANY incorrect build variable {data} #2776

Closed
wmwart opened this issue Jan 17, 2019 · 2 comments
Closed

ra-data-graphql-simple UPDATE_MANY incorrect build variable {data} #2776

wmwart opened this issue Jan 17, 2019 · 2 comments
Labels

Comments

@wmwart
Copy link

wmwart commented Jan 17, 2019

What you were expecting:
When creating the BulkArchiveButton, I expected correct execution mutation

What happened instead:
UPDATE_MANY a few times causes the execution of the UPDATE
the required ID argument is not passed to the {data} parameter

Steps to reproduce:
try to update any resource through the CustomBulkActionButton

Other information:
Wrote the BulkArchiveButton as in the example in the documentation:

class BulkArchiveButton extends Component {
    handleArchive = () => {
        const {  basePath, resource, selectedIds, startUndoable } = this.props;
        startUndoable(
            crudUpdateMany(resource, selectedIds, { isArchved: true }, basePath)
        );
    };
    render() {
        const { className, classes, filterValues } = this.props;
        return (
            <Button 
                size="small"
                variant="outlined"
                label="raExt.action.archive"
                onClick={this.handleArchive}
                className={`${classes.button} ${classes.archiveButton} ${className}`}
            >
                <ArchiveIcon />
            </Button>
        );
    }
}

This is the request this button sends:
default

That's what gets a response:
default

To solve the problem fixed

C:...\ui-react-admin\node_modules\ra-data-graphql-simple\esm\index.js

...
               if (fetchType === UPDATE_MANY) {
                var ids = params.ids, otherParams_2 = __rest(params, ["ids"]);
                return Promise.all(params.ids.map(function (id) {
                    
                 //return defaultDataProvider(UPDATE, resource, __assign({ id: id }, otherParams_2));
                    return defaultDataProvider(UPDATE, resource, {data:__assign({ id: id }, otherParams_2.data)});

                })).then(function (results) {
                    var data = results.reduce(function (acc, _a) {
                        var data = _a.data;
                        return acc.concat([data.id]);
                    }, []);
                    return { data: data };
                });
            }
...

Please, fix for next release.
Environment

  • React-admin version: 2.6.0
@fzaninotto
Copy link
Member

ping @djhi

@djhi
Copy link
Contributor

djhi commented Jan 28, 2019

Can you make a PR to fix this ?

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.

4 participants