Files
klz-cables.com/.pnpm-store/v10/files/43/3c537995787ffcc74e986fec149e37d1dbf7d247e7bbfbeb9ffb53968b92b78740850151041733326337b57ce91c4a8d39b4fdaeed50d742b284bd625e734e
Marc Mintel 5397309103
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
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

85 lines
2.9 KiB
Plaintext

/// <reference types="node" />
import type { Middleware, ParameterizedContext, Response } from 'koa';
import type { IncomingMessage } from 'http';
import { HandlerOptions as RawHandlerOptions, OperationContext } from '../handler';
import { RequestParams } from '../common';
/**
* The context in the request for the handler.
*
* @category Server/koa
*/
export interface RequestContext {
res: Response;
}
/**
* The GraphQL over HTTP spec compliant request parser for an incoming GraphQL request.
*
* If the HTTP request _is not_ a [well-formatted GraphQL over HTTP request](https://graphql.github.io/graphql-over-http/draft/#sec-Request), the function will respond
* on Koa's `ParameterizedContext` response and return `null`.
*
* If the HTTP request _is_ a [well-formatted GraphQL over HTTP request](https://graphql.github.io/graphql-over-http/draft/#sec-Request), but is invalid or malformed,
* the function will throw an error and it is up to the user to handle and respond as they see fit.
*
* ```js
* import Koa from 'koa'; // yarn add koa
* import mount from 'koa-mount'; // yarn add koa-mount
* import { parseRequestParams } from 'graphql-http/lib/use/koa';
*
* const app = new Koa();
* app.use(
* mount('/', async (ctx) => {
* try {
* const maybeParams = await parseRequestParams(ctx);
* if (!maybeParams) {
* // not a well-formatted GraphQL over HTTP request,
* // parser responded and there's nothing else to do
* return;
* }
*
* // well-formatted GraphQL over HTTP request,
* // with valid parameters
* ctx.response.status = 200;
* ctx.body = JSON.stringify(maybeParams, null, ' ');
* } catch (err) {
* // well-formatted GraphQL over HTTP request,
* // but with invalid parameters
* ctx.response.status = 400;
* ctx.body = err.message;
* }
* }),
* );
*
* app.listen({ port: 4000 });
* console.log('Listening to port 4000');
* ```
*
* @category Server/koa
*/
export declare function parseRequestParams(ctx: ParameterizedContext): Promise<RequestParams | null>;
/**
* Handler options when using the koa adapter.
*
* @category Server/koa
*/
export type HandlerOptions<Context extends OperationContext = undefined> = RawHandlerOptions<IncomingMessage, RequestContext, Context>;
/**
* Create a GraphQL over HTTP spec compliant request handler for
* the Koa framework.
*
* ```js
* import Koa from 'koa'; // yarn add koa
* import mount from 'koa-mount'; // yarn add koa-mount
* import { createHandler } from 'graphql-http/lib/use/koa';
* import { schema } from './my-graphql-schema';
*
* const app = new Koa();
* app.use(mount('/', createHandler({ schema })));
*
* app.listen({ port: 4000 });
* console.log('Listening to port 4000');
* ```
*
* @category Server/koa
*/
export declare function createHandler<Context extends OperationContext = undefined>(options: HandlerOptions<Context>): Middleware;