Skip to content
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

Merged
merged 5 commits into from
Oct 24, 2022
Merged

Fix fetch query preview #1165

merged 5 commits into from
Oct 24, 2022

Conversation

bytasv
Copy link
Contributor

@bytasv bytasv commented Oct 17, 2022

image

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 see Object { }.

image

It seems that this is effect of using custom nodeRenderer, if I removed nodeRenderer, I get result close to what I expect to see in console:
image

And with empty object:
image

I kept this part as is, lemme know if you think we should change it as well

@bytasv bytasv added the feature: Connections PostgreSQL, MySQL, etc. label Oct 17, 2022
@bytasv bytasv requested a review from Janpot October 17, 2022 07:53
@bytasv bytasv self-assigned this Oct 17, 2022
@render
Copy link

render bot commented Oct 17, 2022

@Janpot
Copy link
Member

Janpot commented Oct 17, 2022

It seems that this is effect of using custom nodeRenderer, if I removed nodeRenderer, I get result close to what I expect to see in console:

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 nodeRenderer. By redesign I mean: instead of just showing a json view for the whole object, we render each global variable with a JsonView on its own. But we can do that in follow-up.

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 (
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean this alert? 👇 (sorry for code screenshot 🙈 )
image

Would you like to display that only when undefined is returned or some other conditions as well?

Copy link
Member

@Janpot Janpot Oct 19, 2022

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 is undefined, and we make sure the JsonView can show undefined 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 the JsonView) 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

Copy link
Contributor Author

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

@bytasv
Copy link
Contributor Author

bytasv commented Oct 17, 2022

I think if we redesign a little bit how the global scope explorer works, we can remove this nodeRenderer. By redesign I mean: instead of just showing a json view for the whole object, we render each global variable with a JsonView on its own. But we can do that in follow-up.

Are you talking about this part:
image

The logic would be that we iterate through globalScope keys and render each using JsonView without nodeRenderer defined?

@oliviertassinari oliviertassinari added the bug 🐛 Something doesn't work label Oct 19, 2022
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 20, 2022
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 21, 2022
@bytasv
Copy link
Contributor Author

bytasv commented Oct 21, 2022

image

Added this warning back, but only if transform returns undefined, @Janpot lemme know if I understood your suggestions correctly

@bytasv bytasv requested a review from Janpot October 21, 2022 13:19
Copy link
Member

@Janpot Janpot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 looks good

@bytasv bytasv merged commit 545dc0f into master Oct 24, 2022
@bytasv bytasv deleted the fix-fetch-preview-logic branch October 24, 2022 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work feature: Connections PostgreSQL, MySQL, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants