import fetch from "isomorphic-unfetch"; import { NextPage } from "next"; import { useEffect, useState } from "react"; import NoSSR from "react-no-ssr"; import styles from "~/components/styles.module.scss"; import { GRAPHQL_ENDPOINT } from "~/components/hooks/with-apollo"; const GraphiQLPage: NextPage<{}> = () => ( Loading...}>
); const GraphiQL: React.FC<{}> = () => { const [GraphiQL, setGraphiQL] = useState(); useEffect(() => { import("graphiql").then(imported => { setGraphiQL(() => imported.default); }); }, []); if (typeof window === "undefined") { return
javascript required
; } else { if (!GraphiQL) { return
loading
; } else { return (
fetch(GRAPHQL_ENDPOINT, { body: JSON.stringify(query), headers: { "Content-Type": "application/json" }, method: "post", }).then(response => response.json()) } />
); } } }; export default GraphiQLPage;