-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
Fix fetch query preview #1165
Fix fetch query preview #1165
Conversation
Your Render PR Server URL is https://toolpad-pr-1165.onrender.com. Follow its progress at https://dashboard.render.com/web/srv-cd6gjuaen0hsgl6sno1g. |
I believe this was originally done to improve how that global scope explorer looks (It was the first thing we used this JsonView for I think). When just used as an output it doesn't work well. I think if we redesign a little bit how the global scope explorer works, we can remove this Just added one comment about what to show in the preview, other than that, I think this lgtm |
@@ -223,35 +212,14 @@ function ResolvedPreview({ preview }: ResolvedPreviewProps): React.ReactElement | |||
|
|||
const { untransformedData } = preview; | |||
|
|||
if (!untransformedData || isEmpty(untransformedData)) { | |||
if (untransformedData === undefined) { | |||
return ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an idea, but would it make sense to both show the JsonView
with undefined
and the Alert? Basically we'd always show the exact JSON output, but in some cases we show an extra warning alongside of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way I was imagining it in #1083 is:
- We always show a
JsonView
, even if the data isundefined
, and we make sure theJsonView
can showundefined
instead of nothing.
The stretch goals of #1083 would be
- In the transform editor tab, add more text and/or a docs link with some more information about what it's for and what code it expects
- When the transformed data is
undefined
. show a warning (above or under theJsonView
) that points out that there's a potential issue with the transform function.
These last two are nice-to-haves IMO and probably require a bit more thinking about the content
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO all suggestions are easily doable right now. I could make the changes and just render same text that I've used before without auto tab switching. I can also add a link to a tab on transform
word so user could quickly jump into that if needed
cd86c74
to
dd0246f
Compare
Added this warning back, but only if transform returns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 looks good
Follow up for Improve preview feedback in fetch query #1153 (comment)
Kept only logic which checks if untransformed data is undefined
Rendering
undefined
as a returned value inJsonView
One thing I'm not sure if it's fine - when api returns empty object, preview just show
Object
which to me seems a bit confusing (I'd expect maybe to seeObject { }
.It seems that this is effect of using custom
nodeRenderer
, if I removednodeRenderer
, I get result close to what I expect to see in console:And with empty object:
I kept this part as is, lemme know if you think we should change it as well