You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import { pick } from 'lodash';
|
|
|
|
import React from 'react';
|
|
|
|
import { createRoot } from 'react-dom/client';
|
|
|
|
import { NamedPage } from 'vj/misc/Page';
|
|
|
|
import { request } from 'vj/utils';
|
|
|
|
|
|
|
|
const defaultQuery = `\
|
|
|
|
query Example(
|
|
|
|
$name: String!
|
|
|
|
) {
|
|
|
|
user(uname: $name) {
|
|
|
|
_id
|
|
|
|
uname
|
|
|
|
}
|
|
|
|
}`;
|
|
|
|
|
|
|
|
export default new NamedPage('api', async () => {
|
|
|
|
const { GraphiQL } = await import('graphiql');
|
|
|
|
GraphiQL.Logo = function () {
|
|
|
|
return <p></p>;
|
|
|
|
} as any;
|
|
|
|
createRoot(document.getElementById('main')!).render(
|
|
|
|
<GraphiQL
|
|
|
|
fetcher={(body, opts = {}) => request.post('/api', body, pick(opts, 'headers'))}
|
|
|
|
defaultQuery={defaultQuery}
|
|
|
|
variables='{"name": "Hydro"}'
|
|
|
|
/>,
|
|
|
|
);
|
|
|
|
});
|