Skip to content

Commit

Permalink
feat: support shouldPersistHeaders
Browse files Browse the repository at this point in the history
  • Loading branch information
chentsulin committed Nov 27, 2021
1 parent 4d48034 commit ea8fd12
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/renderGraphiQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ export interface GraphiQLOptions {
*/
headerEditorEnabled?: boolean;

/**
* An optional boolean which enables headers to be saved to local
* storage when true.
* Defaults to false.
*/
shouldPersistHeaders?: boolean;

/**
* By passing an object you may change the theme of GraphiQL.
*/
Expand Down Expand Up @@ -105,6 +112,7 @@ export function renderGraphiQL(
const operationName = data.operationName;
const defaultQuery = options?.defaultQuery;
const headerEditorEnabled = options?.headerEditorEnabled;
const shouldPersistHeaders = options?.shouldPersistHeaders;
const editorTheme = getEditorThemeParams(options?.editorTheme);

return `<!--
Expand Down Expand Up @@ -246,6 +254,7 @@ add "&raw" to the end of the URL within a browser.
operationName: ${safeSerialize(operationName)},
defaultQuery: ${safeSerialize(defaultQuery)},
headerEditorEnabled: ${safeSerialize(headerEditorEnabled)},
shouldPersistHeaders: ${safeSerialize(shouldPersistHeaders)}
}),
document.getElementById('graphiql')
);
Expand Down

0 comments on commit ea8fd12

Please sign in to comment.