Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit a7c3805

Browse files
authored
feat: support shouldPersistHeaders (#788)
This exposes the shouldPersistHeaders option in GraphiQL, useful when you require authentication for introspection.
1 parent 474287a commit a7c3805

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/renderGraphiQL.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ export interface GraphiQLOptions {
2121
*/
2222
headerEditorEnabled?: boolean;
2323

24+
/**
25+
* An optional boolean which enables headers to be saved to local
26+
* storage when true.
27+
* Defaults to false.
28+
*/
29+
shouldPersistHeaders?: boolean;
30+
2431
/**
2532
* A websocket endpoint for subscription
2633
*/
@@ -63,6 +70,7 @@ export function renderGraphiQL(
6370
const operationName = data.operationName;
6471
const defaultQuery = options?.defaultQuery;
6572
const headerEditorEnabled = options?.headerEditorEnabled;
73+
const shouldPersistHeaders = options?.shouldPersistHeaders;
6674
const subscriptionEndpoint = options?.subscriptionEndpoint;
6775
const websocketClient = options?.websocketClient ?? 'v0';
6876

@@ -262,6 +270,7 @@ add "&raw" to the end of the URL within a browser.
262270
operationName: ${safeSerialize(operationName)},
263271
defaultQuery: ${safeSerialize(defaultQuery)},
264272
headerEditorEnabled: ${safeSerialize(headerEditorEnabled)},
273+
shouldPersistHeaders: ${safeSerialize(shouldPersistHeaders)}
265274
}),
266275
document.getElementById('graphiql')
267276
);

0 commit comments

Comments
 (0)