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

move context methods into hooks #2450

Merged
merged 5 commits into from
May 31, 2022

Conversation

thomasheyenbrock
Copy link
Collaborator

This came up through #2442. Using contexts in other context providers restricts us to render context providers in a specific order and could cause conflicts if everything is put into context values. It's much more flexible to have individual hooks that consume all the necessary contexts themselves and use these in the components.

This PR extracts the methods we currently moved to the editor context into hooks, namely copy, merge, prettify, and autoCompleteLeads. This removes the dependency of the EditorContext on the SchemaContext, i.e. we don't need to call useSchemaContext in the EditorContextProvider anymore.

@changeset-bot
Copy link

changeset-bot bot commented May 30, 2022

🦋 Changeset detected

Latest commit: f60b0c8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@graphiql/react Minor
graphiql Patch

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

@thomasheyenbrock thomasheyenbrock force-pushed the refactor/move-context-methods-to-hooks branch from f35d370 to eaa9160 Compare May 30, 2022 08:06
@codecov
Copy link

codecov bot commented May 30, 2022

Codecov Report

Merging #2450 (f60b0c8) into main (2d91916) will increase coverage by 3.89%.
The diff coverage is 69.73%.

@@            Coverage Diff             @@
##             main    #2450      +/-   ##
==========================================
+ Coverage   65.70%   69.60%   +3.89%     
==========================================
  Files          85       71      -14     
  Lines        5106     4392     -714     
  Branches     1631     1455     -176     
==========================================
- Hits         3355     3057     -298     
+ Misses       1747     1330     -417     
- Partials        4        5       +1     
Impacted Files Coverage Δ
packages/codemirror-graphql/src/hint.ts 94.73% <ø> (ø)
packages/codemirror-graphql/src/lint.ts 100.00% <ø> (ø)
packages/codemirror-graphql/src/results/mode.ts 47.05% <ø> (ø)
...kages/codemirror-graphql/src/utils/forEachState.ts 100.00% <ø> (ø)
packages/codemirror-graphql/src/utils/hintList.ts 95.65% <ø> (ø)
...ckages/codemirror-graphql/src/utils/mode-indent.ts 0.00% <0.00%> (ø)
packages/codemirror-graphql/src/variables/hint.ts 89.70% <ø> (ø)
packages/codemirror-graphql/src/variables/mode.ts 79.48% <ø> (ø)
packages/graphiql-react/src/editor/whitespace.ts 100.00% <ø> (ø)
packages/graphiql-toolkit/src/storage/query.ts 36.73% <ø> (ø)
... and 90 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a0b02ed...f60b0c8. Read the comment docs.

Base automatically changed from refactor/context-hooks to main May 31, 2022 06:52
@thomasheyenbrock thomasheyenbrock force-pushed the refactor/move-context-methods-to-hooks branch from eaa9160 to f60b0c8 Compare May 31, 2022 06:53
@github-actions
Copy link
Contributor

The latest changes of this PR are not available as canary, since there are no linked changesets for this PR.

@thomasheyenbrock thomasheyenbrock merged commit 1e6fc68 into main May 31, 2022
@thomasheyenbrock thomasheyenbrock deleted the refactor/move-context-methods-to-hooks branch May 31, 2022 07:00
@acao acao mentioned this pull request May 31, 2022
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.

2 participants