v6: Add a visual query builder (@graphiql/plugin-query-builder)#4352
Draft
trevor-scheer wants to merge 1 commit into
Draft
v6: Add a visual query builder (@graphiql/plugin-query-builder)#4352trevor-scheer wants to merge 1 commit into
@graphiql/plugin-query-builder)#4352trevor-scheer wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: daf647d The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 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 |
New first-party plugin: pick fields from the schema with checkboxes and the operation in the editor stays in sync both ways. Every change runs through a parse, mutate, reprint cycle over the `graphql` AST, so the builder and the editor never drift apart. Covers a schema tree of collapsible root types (scalar fields are checkboxes, composites are expand-only), argument inputs typed per argument (scalars, enums, lists, and recursive input objects including the list-of-input-objects case), promoting arguments to and from variables with orphaned-variable cleanup, and union and interface type conditions via `... on TypeName` selectors. The builder reads and edits the operation the editor cursor sits in, and moving the cursor expands the tree down to the field it lands on. The plugin is default-installed in the `graphiql` meta-package; omit it from your `plugins` list to opt out. Also changes `@graphiql/react`: the active `operationName` now follows the editor cursor, so the Run button, the operation dropdown, and operation-aware plugins reflect the operation you are editing.
f66df5d to
daf647d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New package
@graphiql/plugin-query-builder, a first-party visual query builder for GraphiQL. People have asked for one since #734.Pick fields from the schema with checkboxes and the operation in the editor stays in sync, both ways. Every change runs through the same parse → mutate → reprint cycle using the
graphqlpackage's AST utilities, so the builder and the editor never drift apart.What it covers:
$namein the operation; an "Inline argument" toggle reverses it. Suggested names are unique across the whole document, and removing a field cleans up any variable it orphaned.... on TypeNameselector; checking a field inside one adds it within that inline fragment. Interface fields shared by every type can also be selected directly, without a type condition. Named fragments already in the document are listed.The plugin is default-installed in the
graphiqlmeta-package, so the rail icon is present with no extra configuration. Omit it from yourpluginslist to opt out.This also makes one change to
@graphiql/react: the activeoperationNamenow follows the editor cursor, so the Run button, the operation dropdown, and operation-aware plugins reflect the operation you are editing. See thegraphiql@6migration guide for details.Test plan
$name, and the button now reads "Inline argument". Click it; confirm the literal returns and the Variables entry is gone.+Ncount, and editing an argument in one operation doesn't jump the builder to the other. Confirm only the active operation's root type is enabled.... on TypeName(with no prior selection on the field) and confirm... on TypeName { __typename }is added. Check a field inside it; confirm it lands inside the fragment, not as a sibling. For an interface, confirm its shared fields can be checked directly.$namedefinition and its Variables entry are both removed, leaving valid GraphQL.Refs: #734, #4219