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

Add support for onPrettifyQuery callback to enable customised query formatting #3640

Closed
wants to merge 3 commits into from

Conversation

i-like-robots
Copy link

@i-like-robots i-like-robots commented Jul 2, 2024

This adds a new optional callback function named onPrettifyQuery to enable the use of customised query formatting, such as integrating Prettier. This is a very quick POC implementation but I'm happy to invest more time if the feature is accepted as being valuable.

When provided this callback will be invoked when the user formats the current contents of the query editor. It has no affect on the header or variable editors. The callback will receive the current value of the query editor and should return a string containing the formatted query. When the callback is not provided it will fallback to the current parse/print logic.

Intended to resolve #1517 and #3385.

Copy link

changeset-bot bot commented Jul 2, 2024

🦋 Changeset detected

Latest commit: 0bc748a

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

This PR includes changesets to release 4 packages
Name Type
@graphiql/react Minor
graphiql Minor
@graphiql/plugin-code-exporter Major
@graphiql/plugin-explorer Major

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

Copy link

linux-foundation-easycla bot commented Jul 2, 2024

CLA Not Signed

@dimaMachina
Copy link
Collaborator

@i-like-robots can you sign CLA?

Copy link

codecov bot commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 67.28%. Comparing base (40bbd61) to head (0bc748a).
Report is 2 commits behind head on main.

Files Patch % Lines
packages/graphiql-react/src/editor/hooks.ts 25.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3640      +/-   ##
==========================================
- Coverage   67.30%   67.28%   -0.02%     
==========================================
  Files         121      121              
  Lines        7016     7018       +2     
  Branches     2263     2246      -17     
==========================================
  Hits         4722     4722              
- Misses       2277     2279       +2     
  Partials       17       17              
Files Coverage Δ
packages/graphiql-react/src/editor/query-editor.ts 64.10% <100.00%> (ø)
packages/graphiql/src/components/GraphiQL.tsx 78.41% <100.00%> (ø)
packages/graphiql-react/src/editor/hooks.ts 38.59% <25.00%> (-0.46%) ⬇️

@dimaMachina
Copy link
Collaborator

superseded by #3733

@i-like-robots
Copy link
Author

Thanks @dimaMachina 🙏

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.

API Proposal: Code Formatting, Prettier
2 participants