diff options
Diffstat (limited to 'source/http.ts')
| -rwxr-xr-x | source/http.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/source/http.ts b/source/http.ts index c4a70c8..39d6866 100755 --- a/source/http.ts +++ b/source/http.ts @@ -54,6 +54,14 @@ export function GraphQLHTTP< ...options }: GQLOptions<Ctx, Req>): GraphQLHandler<Req> { return async (request: Req) => { + if (options.graphiql) { + const { serveAsset } = await import("./graphiql/assets.ts"); + const asset = serveAsset(request); + + if (asset) + return asset; + } + if (options.subscriptions && request.headers.get("upgrade")?.toLowerCase() === "websocket") return options.subscriptions(request as unknown as Request); @@ -91,7 +99,7 @@ export function GraphQLHTTP< const playground = renderPlaygroundPage({ ...playgroundOptions, - endpoint: "/graphql" + endpoint: new URL(request.url).pathname }); return new Response(playground, { |