-
Notifications
You must be signed in to change notification settings - Fork 0
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
TanStack Query mutations #297
Comments
Ignore the initial comment above, I was wrong. The OpenAPI Codegen essentially uses TanStack Query under the hood such that any "use" hooks are either "queries" for "getter" calls (GET) or are "mutations" for "setter" calls (POST, PUT, ...). So to use the hooks you need to do something like:
Notice that for this specific example in our app you'd get an internal server error as the Person you are trying to add as an Investigator does not exist in our database but it shows the pattern of what is required. |
Appears that issues close when merging an associated branch into master regardless of other active branches associated with the same issue. Unsure if there's a config setting in GitHub somewhere to change this behaviour on a per issue basis? So, reopening this issue to continue for the active brach A.England is working on. Perhaps we open a specific issue per page we want to change from using the "fetch" calls to the mutation calls. |
I've refactored the investigator panels to work with hooks and mutations instead of the fetch calls (I remain confused as to why they're exported if they don't work as expected). Some of it was straight forward and some wasn't so it's hard to say how much effort will be involved in refactoring the rest of the codebase. I suggest we keep this ticket open as a place to monitor progress overall for this and open separate related issues when working on each page. |
I believe this is now done where possible, so I'll close this issue. We can always reopen at a later date if needed. |
Tracking issue to replace any "fetch" type calls with "use" type calls when accessing the API.
According to TanStack Query Quick Start (from where I lifted this code segment), the general pattern using mutations should be something like:
For our code the 'mutate' generally needs to occur in a form submit handler.
The text was updated successfully, but these errors were encountered: