-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Feature(Devtools): make data of queries editable #5970
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
Hi @bastibuck, I really like your proposal. I will check it out later. I was wondering if another form of manipulation would be better: What do you think? |
☁️ Nx Cloud ReportCI is running/has finished running commands for commit c0244a6. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit c0244a6:
|
That would make updating way easier. I'll take a look on Sunday. Was currently struggling to identify the exact position in the objects and/arrays to update with my approach. I bet it can be done. But as a first take I'd follow your idea. This would also allow for resetting the manually edited data back to what the cache originally had if we treat the manual edits as overrides. |
I've updated the code to use a JSON editor as an initial draft. The previos approach with the input fields and delete buttons is still in the PR but would be removed upon a descion on what path to follow. Concept and reasoningIt uses https://jsoneditoronline.org/ to make
Open issuesRight now the editor doesn't have the greatest UX but it works. The But before grinding out the edges I'd like to get feedback if this is a path we should continue. @TkDodo @vossmalte what's you opinion on this approach? Next steps
|
Hey there! Great work! Taking a look at this. One thing to keep in mind also is that TanStack Query is not opinionated on what the query data should be. So it's not necessary that all query data will always be JSON serializable. A query function could also return a Map, Set, Iterable, etc. @TkDodo in such cases should the editor be disabled? |
we're serializing those values with |
I think I liked the inline editing better 🤔 |
55161dd
to
caf50c3
Compare
Me too! I just pushed a new version where it's possible to update string and number values. How do you like this approach? The types for the new util function are still wonky and Additionally coming back to the original idea of this PR I made arrays clearable and single array items deletable. Don't think it makes a lot of sense to add something similar to other types than array. What do you think? |
Codecov ReportAttention: ❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
... and 80 files with indirect coverage changes 📢 Thoughts on this report? Let us know!. |
@TkDodo @ardeora Added the missing handling for Maps and Sets. Now the handling (deleting and updating) of text and number values inside Arrays, Objects (plain), Sets and Maps is done explicitly and per case. Very happy with how this turned out. Anything else to address? The remaining |
Thank you so much @bastibuck - great work ❤️ |
It would be nice if one could edit data of queries directly inside the devtools without changing the actual return values of a potential mock or real backend running during development.
For example if I wanted to test and develop my UI with an empty list I could just remove all entries from a already fetched list instead of changing the server code to return an empty list, restart that thing and refetch my queries.
I therefor created this very early (visual) draft of making data editable inside devtools.
Will potentially need some guidance on how to best get the activeQuery into the right places to set the data from there onChange/onClick.
Open for suggestions and ideas :)
PS: focusing on string fields first, other types like numbers can follow once the functionality is in place.