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

initial code #1

Merged
merged 53 commits into from
Dec 8, 2021
Merged

initial code #1

merged 53 commits into from
Dec 8, 2021

Conversation

kikkupico
Copy link
Contributor

@kikkupico kikkupico commented Nov 15, 2021

Intro

This PR implements part of the RFC https://github.com/hasura/lux/blob/main/docs/rfcs/20210920_public_graphiql.md

(the second part is implemented by - https://github.com/hasura/lux/pull/3302 )

Design Notes

The UI/UX mimics the console API Explorer page.

Screenshot of API explorer -
image

Screenshot of this component -
image

The 'Relay' control is hidden for now as it's still unclear when we should show it. ( discussed with @wawhal )

The notification styles are also copied from the console UI/UX. (discussed with @martin-hasura )

We have used cypress component testing for the unit tests. RTL was considered and later discarded as it required mocking too many browser libs in this case.

Setup Instructions

See README.md

wawhal
wawhal approved these changes Nov 30, 2021
@wawhal
Copy link

wawhal commented Nov 30, 2021

Approved the PR by mistake.

src/lib/HasuraGraphiQL.tsx Outdated Show resolved Hide resolved
src/lib/HasuraGraphiQL.tsx Outdated Show resolved Hide resolved
src/lib/HasuraGraphiQL.tsx Outdated Show resolved Hide resolved
src/lib/HasuraGraphiQL.tsx Outdated Show resolved Hide resolved
src/lib/HasuraGraphiQL.tsx Show resolved Hide resolved
</table>
<div
className="graphiql-container"
style={{
Copy link

Choose a reason for hiding this comment

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

Why isn't this a class? I don't see anything variable here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason, this didn't work inside the 'graphiql-container` class even after adding !important. Probably some CSS specificity thing I don't fully understand. So, left this as such.

Copy link

Choose a reason for hiding this comment

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

That's probably because graphiql-container is a graphiql specific class and it might not not be trivial to override it.
Would work if we write a separate class and pass the className of this div as graphiql-container custom-class. This doesn't work either?

src/lib/Icons.tsx Outdated Show resolved Hide resolved
src/lib/HasuraGraphiQL.tsx Outdated Show resolved Hide resolved
src/lib/CustomGraphiQL.js Outdated Show resolved Hide resolved
@wawhal
Copy link

wawhal commented Nov 30, 2021

@beaussan do you mind signing off on this too?

src/HasuraGraphiQL.test.tsx Outdated Show resolved Hide resolved
src/HasuraGraphiQL.test.tsx Outdated Show resolved Hide resolved
src/lib/CustomGraphiQL.js Outdated Show resolved Hide resolved
src/lib/HasuraGraphiQL.tsx Outdated Show resolved Hide resolved
src/lib/HasuraGraphiQL.tsx Show resolved Hide resolved
src/lib/HasuraGraphiQL.tsx Outdated Show resolved Hide resolved
src/lib/HasuraGraphiQL.tsx Outdated Show resolved Hide resolved
src/lib/HasuraGraphiQL.tsx Outdated Show resolved Hide resolved
src/lib/fetcher.js Outdated Show resolved Hide resolved
src/reportWebVitals.ts Outdated Show resolved Hide resolved
@kikkupico
Copy link
Contributor Author

@wawhal @beaussan

Have completely rewritten the code. Sorry about the re-review effort but the new code is shorter and simpler than the original and hopefully, easier to review.

Design Choices

Data Flow

image

Debouncing is done to prevent a bug in the code where when header info is typed and the checkbox is clicked without tabbing out, then two introspection queries are sent. Depending on which query wins the race the UI could look inconsistent. The issue is also prevalent in the console. See [here](https://drive.google.com/file/d/1wn0xI_Y0siSFGbiMdppPb11DCtqWtcl9/view?usp=sharing)

Batched State Updates

I have used composite objects along with useState to store related data. Felt this was easier to understand than using useReducer.

Copy link

@wawhal wawhal 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 to me! Added a suggestion, but no biggie.

import * as React from "react";
import { IconChevronRight, IconChevronDown } from "./Icons";

export default function Collapsible({
Copy link

Choose a reason for hiding this comment

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

Nice :)

</table>
<div
className="graphiql-container"
style={{
Copy link

Choose a reason for hiding this comment

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

That's probably because graphiql-container is a graphiql specific class and it might not not be trivial to override it.
Would work if we write a separate class and pass the className of this div as graphiql-container custom-class. This doesn't work either?

src/lib/utils.ts Show resolved Hide resolved
Copy link

@beaussan beaussan left a comment

Choose a reason for hiding this comment

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

Much nicer than the initial version ! Left some small comments, nothing big tho ! 🎉

}) {
const [collapsed, setCollapsed] = React.useState(false);

return (
Copy link

Choose a reason for hiding this comment

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

Nitpicking here, but did you consider https://www.radix-ui.com/docs/primitives/components/collapsible ? It would cover all of the acceptability concern here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didn't really look into the application from an accessibility perspective. Found some more a11y problems. Will add a new GitHub issue to address this. Will update this comment with issue# in a while.

Copy link

Choose a reason for hiding this comment

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

Sounds good to me !

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Captured this concern in #2

src/lib/Collapsible.tsx Outdated Show resolved Hide resolved
src/lib/Collapsible.tsx Outdated Show resolved Hide resolved
@kikkupico kikkupico merged commit e8af591 into master Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants