contiamo / restful-react

A consistent, declarative way of interacting with RESTful backends, featuring code-generation from Swagger and OpenAPI specs 🔥
MIT License
1.87k stars 109 forks source link

RestfulProvider resolve property issue #172

Closed yeldisbayev closed 4 years ago

yeldisbayev commented 5 years ago

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.

Implementatin example

TejasQ commented 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.

fabien0102 commented 4 years ago

Closed by #254

Please tell me if this resolution works for you, if not, let's find a better API all together!