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

Give visual feedback when reloading the schema #516

Merged
merged 7 commits into from
Jan 22, 2018

Conversation

xavxyz
Copy link
Contributor

@xavxyz xavxyz commented Jan 19, 2018

Fixes #379.

Changes proposed in this pull request:

screencast of the change

  • Simple animation on the reload icon when the schema is reloading (↔ GraphQLEditor's onReload method is triggered)

  • Two SVG elements instead of the graphcool-styles SVG icon: when not reloading, show the icon, when reloading, show a spinner

Questions

When developing a GraphQL server, you're changing your schema quite often. This workflow is being steadily improved by allowing CMD + R to reload the schema (#180) and even automatic schema reloads based on filewatching via graphqlconfig (#331).

Where are schema changes broadcasted? I'd love to listen to it and thus providing feedback but I couldn't find the code 🙈

this.renewStacks(schema)
}
} catch (e) {
this.setState({ isReloadingSchema: false })
Copy link
Contributor Author

@xavxyz xavxyz Jan 19, 2018

Choose a reason for hiding this comment

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

What about showing some feedback when reloading the schema fails?

How about displaying a little notification dot (similar how the Twitter feed does it) next to the reload icon which is there until you change/run a query.

Something like a red dot? 🔴

With maybe a tooltip saying "schema couldn't be reloaded because xyz"?

We could reuse the endpointUnreachable state?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we can reuse that state for this purpose.

@xavxyz xavxyz changed the title Give a feedback when reloading the schema Give visual feedback when reloading the schema Jan 19, 2018
`

const showWhenReloading = bool => props =>
props.isReloadingSchema ? Number(bool) : Number(!bool)
Copy link
Contributor Author

@xavxyz xavxyz Jan 19, 2018

Choose a reason for hiding this comment

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

Weird workaround, I got a TS error I couldn't solve by doing:

const Element: StyledComponentClass<any, any, any> = styled.xyz`
	/* ... */
   opacity: ${props => props.isReloadingSchema ? 1 : 0};
`

I've tried to type elements props in place of the first & last any but didn't work 🤐

Copy link
Member

Choose a reason for hiding this comment

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

I'm right now merging in a styled components PR and include a withProps function that will help with this.

You will be able to use the withProps function like this:

import { styled, withProps } from '../styled/styled-components'

export interface Props {
  center?: boolean
}

export const P = withProps<Props>()(styled.div)`
  display: inline-block;
  font-size: 14px;
  text-align: ${p => (p.center ? 'center' : 'left')};
`

I will notify you when it's ready!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, excellent!

Copy link
Member

Choose a reason for hiding this comment

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

@huv1k
Copy link
Collaborator

huv1k commented Jan 19, 2018

Looks good 😊

@timsuchanek
Copy link
Member

Right now, schema changes are not broadcasted, that's a separate issue. We could get that information in the electron app by listening to the local changes of a project.

Copy link
Member

@timsuchanek timsuchanek left a comment

Choose a reason for hiding this comment

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

Besides the typings of the Element styled component, this looks good to me!

@schickling
Copy link
Collaborator

OMG. This looks awesome!

@xavxyz xavxyz force-pushed the feedback-on-reload-schema branch from 18456eb to 87325f6 Compare January 20, 2018 15:35
It depends on state.unreachableEndpoint, also used when sending the introspection query
…chable

+ use sc/keyframes for the pulsing component: styled-components auto-prefix animations to be cross-browser 😊
@xavxyz
Copy link
Contributor Author

xavxyz commented Jan 20, 2018

Types are good to go now!

This topbar thrives passion: I just reverted a simple animation on the error message (19b90a4) to avoid conflicts with #504.

Let's work on the error message in another PR once both are merged?

Copy link
Member

@timsuchanek timsuchanek left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

@timsuchanek
Copy link
Member

I had to do a small merge back from master, but it looks good so far, waiting for the build to succeed now.
What do you exactly mean with error message?
Yes, sounds like keeping it separate is a good idea.

@timsuchanek timsuchanek merged commit 4b5b75f into graphql:master Jan 22, 2018
@xavxyz
Copy link
Contributor Author

xavxyz commented Jan 22, 2018

I meant coupling the endpointUnreachable state and this PR, like on this screencast below 😁

screencast

🍡

@Weakky
Copy link
Contributor

Weakky commented Jan 22, 2018

Wouldn't it be more consistent to just keep your work over mine now? The spinner you made is visible whenever the schema is reloading. When it fails to reach the server endpoint, the reason why there's a spinner is because it continues to try to fetch the schema until it succeeds. Therefore, it doesn't make a lot of sense to have two different spinners for the same underlying action?

@xavxyz
Copy link
Contributor Author

xavxyz commented Jan 22, 2018

When it fails to reach the server endpoint, the reason why there's a spinner is because it continues to try to fetch the schema until it succeeds

Nice, I didn't know that! Makes sense to only show one, you're right.

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.

5 participants