Skip to content

Commit 544cbe1

Browse files
committed
Use default query on adding new tab
1 parent 6d36412 commit 544cbe1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/graphiql-react/src/editor/context.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,14 +366,20 @@ export function EditorContextProvider(props: EditorContextProviderProps) {
366366
headerEditor,
367367
responseEditor,
368368
});
369-
const { onTabChange, defaultHeaders, children } = props;
369+
const { onTabChange, defaultHeaders, defaultQuery, children } = props;
370370

371371
const addTab = useCallback<EditorContextType['addTab']>(() => {
372372
setTabState(current => {
373373
// Make sure the current tab stores the latest values
374374
const updatedValues = synchronizeActiveTabValues(current);
375375
const updated = {
376-
tabs: [...updatedValues.tabs, createTab({ headers: defaultHeaders })],
376+
tabs: [
377+
...updatedValues.tabs,
378+
createTab({
379+
headers: defaultHeaders,
380+
query: defaultQuery ?? DEFAULT_QUERY,
381+
}),
382+
],
377383
activeTabIndex: updatedValues.tabs.length,
378384
};
379385
storeTabs(updated);

0 commit comments

Comments
 (0)