Skip to content

Commit

Permalink
First try to use query and headers props
Browse files Browse the repository at this point in the history
  • Loading branch information
cimdalli committed Oct 30, 2023
1 parent 1f497d3 commit 94b5645
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/graphiql-react/src/editor/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,14 @@ export function EditorContextProvider(props: EditorContextProviderProps) {
headerEditor,
responseEditor,
});
const { onTabChange, defaultHeaders, defaultQuery, children } = props;
const {
onTabChange,
headers,
query,
defaultHeaders,
defaultQuery,
children,
} = props;

const addTab = useCallback<EditorContextType['addTab']>(() => {
setTabState(current => {
Expand All @@ -376,8 +383,8 @@ export function EditorContextProvider(props: EditorContextProviderProps) {
tabs: [
...updatedValues.tabs,
createTab({
headers: defaultHeaders,
query: defaultQuery ?? DEFAULT_QUERY,
headers: headers ?? defaultHeaders,
query: query ?? defaultQuery ?? DEFAULT_QUERY,
}),
],
activeTabIndex: updatedValues.tabs.length,
Expand All @@ -388,6 +395,8 @@ export function EditorContextProvider(props: EditorContextProviderProps) {
return updated;
});
}, [
headers,
query,
defaultHeaders,
defaultQuery,
onTabChange,
Expand Down

0 comments on commit 94b5645

Please sign in to comment.