import { NamedPage } from 'vj/misc/Page'; import request from 'vj/utils/request'; import React from 'react'; import { render } from 'react-dom'; const Logo = () => Hydro API Console ; const defaultQuery = `\ query { user(id: 1) { uname } }`; const page = new NamedPage('api', async () => { const [{ default: GraphiQL }, { buildSchema }, res] = await Promise.all([ import('graphiql'), import('graphql'), request.get('/api?schema'), import('graphiql/graphiql.css'), ]); // @ts-ignore GraphiQL.Logo = Logo; const App = () => ( { const data = await fetch( '', { method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify(graphQLParams), credentials: 'same-origin', }, ); return data.json().catch(() => data.text()); }} /> ); render(, document.getElementById('graphiql')); }); export default page;