Skip to content

Commit 9341d55

Browse files
v6: Add an operation picker to the Run button (#4419)
## Summary - Brings back an explicit way to pick which operation runs. When the document has more than one operation, the Run button grows a caret. Clicking it opens a menu of every operation by name, and picking one sets it as the active operation and runs it, the same behavior the old execute button had. - Cursor tracking is still the default. Moving the cursor into a different operation re-activates it, even after a menu pick, so nothing gets pinned. The menu marks the currently active operation. - An operation that can't run under the current HTTP method (a mutation while GET is selected) shows disabled in the menu, the same block reason already shown on the button itself. - The Run control now has visible `:focus-visible` and `:active` states. Previously only the dead execute-button code had them. - Removed the unused `ExecuteButton` component now that the TopBar owns this menu directly. Keeping both around would leave two copies of the same picker logic. ## Test plan - [x] Write a document with two named operations. The Run button shows a caret sized to match the Run half (same height, one seam). No operation name sits beside the button. - [x] Click the caret. A menu lists both operations, with the active one marked. Pick the one the cursor is *not* in; that operation runs and becomes active. - [x] Move the cursor back into the other operation. It becomes active again (cursor still wins; the pick wasn't sticky) — confirm via the mark in the menu. - [x] Add an operation that's invalid for the current method (e.g. a mutation while on GET). Its menu item is disabled. - [x] With a single operation (or none), no caret appears. The button is a plain Run. - [x] Keyboard: focus the caret, open with Enter/Space, move between operations with arrow keys, press Escape. The menu closes and focus returns to the Run button. - [x] Looks modern: the menu matches the app's other dropdowns (elevated surface, rounded corners, subtle shadow, highlight-on-hover); the caret reads as one control with the green Run pill; both halves show a focus ring on keyboard focus and a press state. Verify in light and dark. Refs: #4288, #4219
1 parent 4fc0682 commit 9341d55

10 files changed

Lines changed: 419 additions & 290 deletions

File tree

.changeset/operation-name-follows-cursor.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
'graphiql': minor
44
---
55

6-
The active operation now follows the editor cursor. As you move the cursor between operations in a multi-operation document, `operationName` updates to the operation the cursor sits in, so the Run button, the operation dropdown, and operation-aware plugins all reflect where you are editing. Previously `operationName` only changed on run-at-cursor or via the operation dropdown.
6+
The active operation now follows the editor cursor. As you move the cursor between operations in a multi-operation document, `operationName` updates to the operation the cursor sits in, so the operation dropdown and operation-aware plugins all reflect where you are editing. Previously `operationName` only changed on run-at-cursor or via the operation dropdown.
77

88
Two consequences if you embed GraphiQL: the `onEditOperationName` callback now fires when the cursor crosses into a different named operation, and a tab containing multiple operations shows the active operation name with a `+N` count of the others. Pinning an operation with the `operationName` prop still overrides cursor tracking.
9+
10+
The Run button now offers an operation picker: in a document with multiple named operations, a dropdown on the Run button lets you choose which operation to run, and the menu marks which operation is currently active. The active operation still follows the editor cursor by default.

packages/graphiql-react/src/components/execute-button/execute-button.test.tsx

Lines changed: 0 additions & 117 deletions
This file was deleted.

packages/graphiql-react/src/components/execute-button/index.css

Lines changed: 0 additions & 44 deletions
This file was deleted.

packages/graphiql-react/src/components/execute-button/index.tsx

Lines changed: 0 additions & 95 deletions
This file was deleted.

packages/graphiql-react/src/components/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export { ExecuteButton } from './execute-button';
21
export { ToolbarButton } from './toolbar-button';
32
export { ToolbarMenu } from './toolbar-menu';
43

0 commit comments

Comments
 (0)