Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
31 lines
964 B
Plaintext
31 lines
964 B
Plaintext
import { renderPlaygroundPage } from 'graphql-playground-html';
|
|
import { createPayloadRequest } from 'payload';
|
|
import { formatAdminURL } from 'payload/shared';
|
|
export const GET = config => async request => {
|
|
const req = await createPayloadRequest({
|
|
config,
|
|
request
|
|
});
|
|
if (!req.payload.config.graphQL.disable && !req.payload.config.graphQL.disablePlaygroundInProduction && process.env.NODE_ENV === 'production' || process.env.NODE_ENV !== 'production') {
|
|
const endpoint = formatAdminURL({
|
|
apiRoute: req.payload.config.routes.api,
|
|
path: req.payload.config.routes.graphQL
|
|
});
|
|
return new Response(renderPlaygroundPage({
|
|
endpoint,
|
|
settings: {
|
|
'request.credentials': 'include'
|
|
}
|
|
}), {
|
|
headers: {
|
|
'Content-Type': 'text/html'
|
|
},
|
|
status: 200
|
|
});
|
|
} else {
|
|
return new Response('Route Not Found', {
|
|
status: 404
|
|
});
|
|
}
|
|
};
|
|
//# sourceMappingURL=playground.js.map |