dielduarte / graphql-devtools

WIP a frameworkless Graphql dev tool focused in a good DX and simplicity - written in TS and state machines just for fun

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rewrite CodeEditor using state machines

dielduarte opened this issue · comments

So @StanleySathler, I've drafted some ideas that I think can guide us to finish the code editor

first here's the list of code editor features, in the version 1.0

  • copy
  • refetch ? I think we can move it to the next milestone...
  • switch contexts (query or mutation, variables, headers)

Copy

Screen Shot 2020-04-04 at 4 10 48 AM

Screen Shot 2020-04-04 at 4 10 57 AM

Screen Shot 2020-04-04 at 4 11 04 AM

I think we don't need a loading state in this case, since the copy function is pretty fast, so I think doesn't worth the effort. after we've got to the success or error state, it should back to the idle state after some milliseconds defined (something like 500ms).

Refetch

Screen Shot 2020-04-04 at 4 11 20 AM

Screen Shot 2020-04-04 at 4 11 28 AM

Screen Shot 2020-04-04 at 4 41 01 AM

  • it should basically get all data we have query/mutation, variables and headers and send a new request.
  • in loading state, let's make the icon rotate smoothly
  • After the request completed it should back to the idle state and select the newest request in the list
  • if the request is completed with an error, we show the error state and then after some milliseconds we back to the idle state.

switch contexts

I thought tabs wouldn't be the best solution since we will have the query filters at the top and other stuff, so I came up with this idea:

Screen Shot 2020-04-04 at 4 09 36 AM

hovering options, I thought about just a slide effect showing the rest of the word:

Screen Shot 2020-04-04 at 4 09 45 AM

Screen Shot 2020-04-04 at 4 10 36 AM

in these examples below, let's suppose the user has selected variables, in the first example he was opening a query so the query goes to the options with its color (green):

Screen Shot 2020-04-04 at 4 09 58 AM

in the example below he was opening a mutation so the mutation goes to the options with its color (orange):

Screen Shot 2020-04-04 at 4 10 17 AM

I may show up with some state machine ideas tomorrow, let me know what do u think! 👊

obs: ignore spaces mistakes, I'm not a good designer hehe let's make it better in code

here's a state machine draft for that, let me know what do you think. in the code will need some DRY applied, but as I said, just a draft.

https://xstate.js.org/viz/?gist=c87dd4a0bd89e2bc91db2ad18403a4ab

Thanks for the hard work preparing all these details, @dielduarte! 🌟

Due the lack of experience handling state machines with State, so far, I don't have anything extra to add - perhaps in the near future I can provide further feedback. For now, I'm just planning to put my fingers to work upon this.

Quick question: do you foresee any kind of situation that could lead to a failed "copy to the clipboard"?

@StanleySathler Honestly, I don't think this is gonna happen especially due to the simplicity of the copy helper function.

you can either skip this state for a while or maybe involve the fn in a try-catch and treat any possible error as failed, both options I'm okay with!