FusionWorks / react-admin-nestjsx-crud-dataprovider

Data provider which integrates React Admin with NestJS CRUD library
132 stars 26 forks source link

Invalid mapping of parameters - empty string #21

Open daugsbi opened 4 years ago

daugsbi commented 4 years ago

Hi, thanks a lot for this dataprovider. It works pretty well. I've just stumbled over the following problem.

Reproduction

Create a ReferenceInput with an AutocompleteInput. The query that is build at the initialization (Empty search string) is the following, which results in an "Invalid filter value" backend error. http://API/users?filter[0]=email||cont&limit=100&page=1&sort[0]=email%2CASC&offset=0

<ReferenceInput
        label="Benutzer"
        source="userId"
        reference="users"
        validate={[required()]}
        sort={{ field: "email", order: "ASC" }}
        perPage={100}
        // This results in an error
        filterToQuery={(search: string) => ({ email: search })}
        // This is a workaround
        filterToQuery={(search: string) => ({ email: search ? search : " "  })}
     >
        <AutocompleteInput optionText="email" optionValue="id" />
</ReferenceInput>