UNPKG

graphdb-workbench

Version:
2 lines 3.25 kB
export const __webpack_id__=67097;export const __webpack_ids__=[67097];export const __webpack_modules__={67097:(e,t,r)=>{r.r(t),r.d(t,{graphql_playground_component:()=>c});var o=r(14119);class a{static loadJavaScript(e,t=!1){return new Promise((r,o)=>{if(document.querySelector(`script[src="${e}"]`))r();else{const a=document.createElement("script");a.setAttribute("src",e),a.async=t,a.addEventListener("load",()=>r()),a.addEventListener("error",()=>{console.error(`Failed to load script: ${e}`),o(new Error(`Failed to load script: ${e}`))}),document.head.appendChild(a)}})}static loadCss(e){return new Promise(t=>{if(!document.querySelector(`link[href="${e}"]`)){const t=document.createElement("link");t.setAttribute("href",e),t.rel="stylesheet",t.type="text/css",document.head.appendChild(t)}t()})}}class i{static toFetcherConfiguration(e){return{url:e.endpoint,headers:e.headers,onAbortQuery:e.onAbortQuery}}}class n{static toGraphiQLConfiguration(e){return{defaultEditorToolsVisibility:!1,selectedLanguage:e.selectedLanguage,defaultQuery:e.defaultQuery,translations:e.translations,fetcher:window.GraphiQL.createFetcher(i.toFetcherConfiguration(e)),plugins:[window.GraphiQLPluginExplorer.explorerPlugin()]}}}class s{constructor(e){this.endpoint=e.endpoint,this.headers=e.headers,this.selectedLanguage=e.selectedLanguage||"en",this.translations=e.translations,this.defaultQuery=e.defaultQuery||" "}}const c=class{constructor(e){(0,o.r)(this,e),this.abortQuery=(0,o.c)(this,"abortQuery",7),this.configuration=void 0}configurationChanged(e){this.init(e)}setLanguage(e){return this.graphiQlConfiguration&&(this.graphiQlConfiguration.selectedLanguage=e||"en",this.renderGraphiQL()),Promise.resolve()}async componentWillLoad(){const e="./assets/";try{await a.loadJavaScript((0,o.g)(`${e}react.development.js`)),await a.loadJavaScript((0,o.g)(`${e}react-dom.development.js`)),await a.loadJavaScript((0,o.g)(`${e}graphiql.min.js`)),await a.loadJavaScript((0,o.g)(`${e}explorer.index.umd.js`)),await a.loadCss((0,o.g)(`${e}graphiql.min.css`)),await a.loadCss((0,o.g)(`${e}explorer.style.css`))}catch(e){console.error("Error loading assets:",e)}}componentDidLoad(){setTimeout(()=>{this.configuration?this.init(this.configuration):console.error("Configuration is undefined")},500)}disconnectedCallback(){this.reactRoot&&(this.reactRoot.unmount(),this.reactRoot=null)}render(){return(0,o.h)(o.H,{key:"b34fbe948cffd9bec58fc2eb52e46089c6487397"},(0,o.h)("div",{key:"9e7e13e0cd339d7424509b39f495c7bd8a7bcdd0",id:"graphiql"},"Loading..."))}init(e){const t=new s(e);t.onAbortQuery=e=>this.abortQuery.emit(e);const r=document.querySelector("graphql-playground-component #graphiql");r?(this.reactRoot||(this.reactRoot=window.ReactDOM.createRoot(r)),this.graphiQlConfiguration=n.toGraphiQLConfiguration(t),this.renderGraphiQL()):console.error("Container element not found")}renderGraphiQL(){this.reactRoot.render(window.React.createElement(window.GraphiQL,this.graphiQlConfiguration))}static get assetsDirs(){return["assets"]}static get watchers(){return{configuration:["configurationChanged"]}}};c.style="graphql-playground-component{display:block;height:100vh}#graphiql{display:block;height:100%}"}}; //# sourceMappingURL=67097.47c73ad11510701f8323.bundle.js.map