Skip to content

Commit

Permalink
feat: tabs (#2197)
Browse files Browse the repository at this point in the history
Co-authored-by: Rikki Schulte <rikki.schulte@gmail.com>
Co-authored-by: timsuchanek <tim.suchanek@gmail.com>
  • Loading branch information
3 people authored Mar 27, 2022
1 parent 81c9419 commit 3137a6c
Show file tree
Hide file tree
Showing 11 changed files with 729 additions and 20 deletions.
6 changes: 6 additions & 0 deletions .changeset/lemon-eagles-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"graphiql": minor
---

Now featuring: tabs! 🥳 🍾 just opt-in with new prop `<GraphiQL tabs />`.
You can also both opt-in and provide a handler via `<GraphiQL tabs={{ onTabsChange }} />`!
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"lint-staged": {
"*.{js,ts,jsx,tsx}": [
"eslint --fix",
"prettier --write"
"prettier --write",
"jest"
],
"*.{md,html,json,css}": [
"prettier --write"
Expand Down
12 changes: 12 additions & 0 deletions packages/graphiql/resources/renderExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ function onEditOperationName(newOperationName) {
updateURL();
}

function onTabChange(tabsState) {
const activeTab = tabsState.tabs[tabsState.activeTabIndex];
parameters.query = activeTab.query;
parameters.variables = activeTab.variables;
parameters.headers = activeTab.headers;
parameters.operationName = activeTab.operationName;
updateURL();
}

function updateURL() {
var newSearch =
'?' +
Expand Down Expand Up @@ -127,6 +136,9 @@ ReactDOM.render(
headerEditorEnabled: true,
shouldPersistHeaders: true,
inputValueDeprecation: true,
tabs: {
onTabChange: onTabChange,
},
}),
document.getElementById('graphiql'),
);
Loading

0 comments on commit 3137a6c

Please sign in to comment.