Closed yeldisbayev closed 4 years ago
Hey @yeldisbayev! Thank you for opening this issue! Apologies for the late response!
I think this update to the global resolve
function could actually be quite useful. I'd love to spend some time on this, but I'd first like to offer you the opportunity to implement it and open a pull request. Is that something you'd be interested in?
Alternatively, each component (Get
/Mutate
) and hook (useGet
/useMutate
) also supports a resolve
function that might give you the functionality you're looking for, since useMutate
is used for non GET
HTTP verbs. Perhaps that might be worth exploring first?
Happy to hear your thoughts and ideas.
Closed by #254
Please tell me if this resolution works for you, if not, let's find a better API all together!
Describe the bug Hi, thanks first of all for your work. I have trouble on resolving server response on RestfulProvider. Its doesn't work for me.
Code example
Also I have a trouble with mocking server(I use Swagger Hub Virtual server), especially with identification codes. As I understand, RestfulProvider resolve prop function is global for any requests. It will be convenient if we have opportunity to write separate resolve functions by GET, POST, PUT, DELETE request types. This changes may resolve mocking problem of response body id filed mocking on the project. For example(todo list app): we have TodoList, TodoItem, CreateTodoForm components.
TodoForm Here we create new todo, and get from response new todo item with const id and add new todo item to the TodoList. After every request we will get same todo with same id, it broke React's list mapping TodoItem key property uniqueness requirement. If we can write seperate resolve functions for request method types, and after every post request generate new unique id on every response.
TodoItem Here we changing todo status(done or not). It will be good, if resolve function gets request body(changed todo with id), response body. Swagger generated server also return static response body maybe with another id. If we can get request body, we may set necessary id and status. We can write one function on RestfulProvider resolve prop especially only for PUT requests.
Implementatin example