File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
packages/libraries/render-laboratory/src Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change 11import type { GraphiQLOptions } from 'graphql-yoga' ;
2+ import type { LaboratoryProps } from '@graphql-hive/laboratory' ;
23import {
34 editorWorkerService ,
45 favicon ,
@@ -9,6 +10,31 @@ import {
910 typescriptWorker ,
1011} from './laboratory.js' ;
1112
13+ const mapGraphiQLOptionsToLaboratoryProps = ( opts ?: GraphiQLOptions ) : LaboratoryProps => {
14+ if ( ! opts ) {
15+ return { } ;
16+ }
17+
18+ return {
19+ defaultSettings : {
20+ fetch : {
21+ credentials : opts . credentials ?? 'same-origin' ,
22+ timeout : opts . timeout ,
23+ retry : opts . retry ,
24+ useGETForQueries : opts . useGETForQueries ,
25+ } ,
26+ subscriptions : {
27+ protocol : opts . subscriptionsProtocol ?? 'WS' ,
28+ } ,
29+ introspection : {
30+ queryName : opts . introspectionQueryName ,
31+ method : opts . method ,
32+ schemaDescription : opts . schemaDescription ,
33+ } ,
34+ } ,
35+ } satisfies LaboratoryProps ;
36+ } ;
37+
1238export const renderLaboratory = ( opts ?: GraphiQLOptions ) => /* HTML */ `
1339 <!doctype html>
1440 <html lang="en">
@@ -63,7 +89,10 @@ export const renderLaboratory = (opts?: GraphiQLOptions) => /* HTML */ `
6389
6490 ${ js } ;
6591
66- HiveLaboratory.renderLaboratory(window.document.querySelector('#root'));
92+ HiveLaboratory.renderLaboratory(
93+ window.document.querySelector('#root'),
94+ ${ JSON . stringify ( mapGraphiQLOptionsToLaboratoryProps ( opts ) ) } ,
95+ );
6796 </script>
6897 </body>
6998 </html>
You can’t perform that action at this time.
0 commit comments