-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
add useQueryEditor
hook to @graphiql/react
#2408
add useQueryEditor
hook to @graphiql/react
#2408
Conversation
🦋 Changeset detectedLatest commit: c60f809 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Minor comment about the slim chance of running into a race condition, looks great!
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 to me! Just 2 clarification questions from my side.
setHeaderEditor() {}, | ||
setQueryEditor() {}, |
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 out of curiosity - why are these empty functions?
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.
TypeScript wants you to provide a default value when creating a context. When actually rendering the context provider we'll pass in the actual value that contains the functions to set the editors in state.
Codecov Report
@@ Coverage Diff @@
## main #2408 +/- ##
==========================================
- Coverage 65.70% 65.51% -0.19%
==========================================
Files 85 81 -4
Lines 5106 5087 -19
Branches 1631 1651 +20
==========================================
- Hits 3355 3333 -22
- Misses 1747 1750 +3
Partials 4 4
Continue to review full report at Codecov.
|
8c32ff7
to
932e5cc
Compare
932e5cc
to
c60f809
Compare
@@ -30,13 +30,16 @@ | |||
"npm": "please_use_yarn_instead" | |||
}, | |||
"scripts": { | |||
"build": "yarn workspace @graphiql/react run build && yarn tsc --clean && yarn tsc", | |||
"build": "yarn build:clean && yarn build:packages && yarn build:graphiql-react && yarn build:graphiql", |
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.
I had to make sure the builds are executed in correct order since we use Vite for @graphiql/react
:
- First build all packages
- Then build
@graphiql/react
- Then build
graphiql
This PR moves over the logic for the query editor into a hook exported from
@graphiql/react
.For now we keep the query also in the state of the
GraphiQL
component. It's a bit more work to move this over to the editor context and hooks as we need to derive the operation facts when the query changes. Will do this in a follow-up PR.