Skip to content

[docs] How to decorate the ra-data-feathers data provider #176

@strarsis

Description

@strarsis

The ra-data-feather provider can't be decorated (for extending or changing its behavior) the usual way (as the example in the react-admin does).
The reason is that the ra-data-feather provider returns a function instead of a JavaScript object with member methods.

That function needs to be wrapped by a decorator function:

import { UPDATE } from 'react-admin';

const addUploadCapabilities = function (dataProvider) {
    return function(type, resource, params) {

        // e.g. for "categories" resource and "UPDATE" type only:
        if(resource === 'categories' && type === UPDATE) {
            // extra stuff, modify `params`/`resource`
            // [...]
            // return [...]; // return to completely skip the `dataProvider` in this case
        }

        // call the underlying `ra-data-feathers` provider
        return dataProvider(type, resource, params);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions