|
|
|
|
@@ -1,19 +1,24 @@
|
|
|
|
|
import { GetServerSideProps } from 'next'
|
|
|
|
|
|
|
|
|
|
import { MainContextT, MainContext, getMainContext } from 'src/frame/components/context/MainContext'
|
|
|
|
|
import { DefaultLayout } from 'src/frame/components/DefaultLayout'
|
|
|
|
|
import { AutomatedPage } from 'src/automated-pipelines/components/AutomatedPage'
|
|
|
|
|
import {
|
|
|
|
|
AutomatedPageContext,
|
|
|
|
|
AutomatedPageContextT,
|
|
|
|
|
getAutomatedPageContextFromRequest,
|
|
|
|
|
} from 'src/automated-pipelines/components/AutomatedPageContext'
|
|
|
|
|
import { useEffect, useRef } from 'react'
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
mainContext: MainContextT
|
|
|
|
|
graphqlExplorerUrl: string
|
|
|
|
|
automatedPageContext: AutomatedPageContextT
|
|
|
|
|
}
|
|
|
|
|
export default function GQLExplorer({ mainContext, graphqlExplorerUrl }: Props) {
|
|
|
|
|
// Use TypeScript's "not null assertion" because `context.page` should
|
|
|
|
|
// will present in main context if it's gotten to the stage of React
|
|
|
|
|
// rendering.
|
|
|
|
|
const page = mainContext.page!
|
|
|
|
|
|
|
|
|
|
export default function GQLExplorer({
|
|
|
|
|
mainContext,
|
|
|
|
|
graphqlExplorerUrl,
|
|
|
|
|
automatedPageContext,
|
|
|
|
|
}: Props) {
|
|
|
|
|
const graphiqlRef = useRef<HTMLIFrameElement>(null)
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
@@ -24,11 +29,8 @@ export default function GQLExplorer({ mainContext, graphqlExplorerUrl }: Props)
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<MainContext.Provider value={mainContext}>
|
|
|
|
|
<DefaultLayout>
|
|
|
|
|
<div className="container-xl px-3 px-md-6 my-4 my-lg-4">
|
|
|
|
|
<h1 id="title-h1">{page.title}</h1>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<AutomatedPageContext.Provider value={automatedPageContext}>
|
|
|
|
|
<AutomatedPage>
|
|
|
|
|
<div>
|
|
|
|
|
{/* eslint-disable-next-line jsx-a11y/iframe-has-title */}
|
|
|
|
|
<iframe
|
|
|
|
|
@@ -42,7 +44,8 @@ export default function GQLExplorer({ mainContext, graphqlExplorerUrl }: Props)
|
|
|
|
|
You must have iframes enabled to use this feature.
|
|
|
|
|
</iframe>
|
|
|
|
|
</div>
|
|
|
|
|
</DefaultLayout>
|
|
|
|
|
</AutomatedPage>
|
|
|
|
|
</AutomatedPageContext.Provider>
|
|
|
|
|
</MainContext.Provider>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
@@ -54,11 +57,13 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) =>
|
|
|
|
|
process.env.NODE_ENV === 'production'
|
|
|
|
|
? 'https://graphql.github.com/explorer'
|
|
|
|
|
: 'http://localhost:3000'
|
|
|
|
|
const automatedPageContext = getAutomatedPageContextFromRequest(req)
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
props: {
|
|
|
|
|
mainContext: await getMainContext(req, res),
|
|
|
|
|
graphqlExplorerUrl,
|
|
|
|
|
automatedPageContext,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|